这是维基百科的定义:
Asynchrony, in computer programming, refers to the occurrence of events independently of the main program flow and ways to deal with such events. These may be "outside" events such as the arrival of signals, or actions instigated by a program that take place concurrently with program execution, without the program blocking to wait for results.
和:
Concurrent computing is a form of computing in which several computations are executed during overlapping time periods—concurrently—instead of sequentially (one completing before the next starts).
在单线程计算的上下文中,“异步”,“非阻塞”和“并发” 是否意味着彼此相同?
如果没有,您能给我一个反例吗?
请注意,我已排除了“并行”一词,因为它表示有多个线程。
最佳答案
非阻塞操作基于两种方法:
请注意:这两个选项都可以进行操作,而不是表示客户端上存在并发或多个线程。您绝对可以使用单个进程(例如coroutines或node.js)来实现这样的系统。
从这个意义上说:非阻塞操作始终是异步-因为您不知道何时会为您带来结果-或何时会给您回电。可以使用并发来实现这两个概念,但是绝对需要这样做。
关于multithreading - 'asynchronous', 'non-blocking'和 'concurrent'相互暗示吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45428408/