'asynchronous'、'non-blocking' 和 'concurrent' 是否相互暗示?

Do 'asynchronous', 'non-blocking', and 'concurrent' imply one another?

维基百科的定义如下:

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).

在单线程计算的上下文中,'asynchronous'、'non-blocking'和'concurrent' 隐含吗?

如果不是,能举个反例吗?

请注意,我已经排除了 'parallel' 这个词,因为它意味着多个线程。

非阻塞和并发实际上并不适用于单线程程序,因为它们指的是管理多线程的方法。非阻塞意味着程序不会等待所有线程完成后再继续,并且只有在有多个线程进行计算时才会发生并发计算。 (如有错误请指正。)

异步是唯一适用于单线程编程的术语,以人工输入、与其他程序通信等形式出现。因此,不,它们在单线程上下文中并不相互暗示程序。

非阻塞操作基于两种方法:

  • 通过简单地返回没有数据(当没有数据可用时 - 在这种情况下,调用者必须自己"come back"然后再次"read")
  • 通过使用 回调。在这种情况下,"blocking" 意味着您等待操作达到某个状态 - 而 "non-blocking" 意味着您触发操作 - 当达到该状态时,您会收到 通知

请注意:这两个选项都暗示客户端并发或多线程。您绝对可以使用单个进程实现这样的系统(例如 coroutines or node.js)。

从这个意义上说:非阻塞操作总是异步——因为你不知道它什么时候会有结果你 - 或者它什么时候会给你回电话。这两个概念 都可以 使用 并发 来实现,但绝对有必要这样做。