idealvin / gitalk

comments for Alvin's blog
0 stars 0 forks source link

Basic concepts | Documents for Coost #96

Open idealvin opened 1 year ago

idealvin commented 1 year ago

https://coostdocs.github.io/en/co/concurrency/coroutine/basic/

Basic concepts of coroutine Coroutines are lightweight scheduling units that run in threads. Coroutines are to threads, similar to threads to processes. There can be multiple threads in a process and multiple coroutines in a thread. The thread where the coroutine runs in is generally called the scheduling thread. The scheduling thread will suspend a coroutine, if it blocks on an I/O operation or sleep was called in the coroutine. When a coroutine is suspended, the scheduling thread will switch to other coroutines waiting to be executed.