【发布时间】:2021-09-01 10:57:00
【问题描述】:
Lua 协程提供协作多线程,一次只能运行一个协程。那么,它们与普通代码块有什么不同(撇开代码中指定等待时间的情况除外)?另外,协程真的运行在不同的线程上吗?
【问题讨论】:
-
there can only be one coroutine running at a time- 是的。do coroutines actually run on different threads?- 没有。how are they even different from a normal block of code?- 每个协程都有自己的堆栈 -
请参考 Lua 参考手册。 Lua 中的编程还深入介绍了协程。不要将 Lua 线程与系统线程混淆。
标签: multithreading lua coroutine