“基于事件”与“异步”相同吗?
最佳答案
不,这并不意味着事件是异步的。
在事件驱动的单线程系统中,您可以触发事件,但它们都是串行处理的。他们可能会在处理过程中让步,但不会发生任何事情 concurrently
,如果他们让步,他们将停止处理并且必须等到再次收到消息才能再次开始处理。
例如 Swing (Java)、Twisted (Python)、Node.js (JavaScript)、EventMachine (Ruby)
所有这些例子都是事件驱动的消息循环,但它们都是单线程的,每个事件都会阻塞同一线程上的所有后续事件。
In programming, asynchronous events are those occurring independently of the main program flow. Asynchronous actions are actions executed in a non-blocking scheme, allowing the main program flow to continue processing.
所以仅仅因为某些东西是 event driven
并不能使它成为 asynchronous
,仅仅因为某些东西是 asynchronous
也不能使它成为 event driven
;更少 并发 。
关于programming-languages - 基于事件 == 异步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7926008/