Difference between a “coroutine” and a “thread”?

前端 未结 6 1775
再見小時候
再見小時候 2020-11-29 14:47

What are the differences between a \"coroutine\" and a \"thread\"?

6条回答
  •  粉色の甜心
    2020-11-29 15:22

    In a word: preemption. Coroutines act like jugglers that keep handing off to each other a well-rehearsed points. Threads (true threads) can be interrupted at almost any point and then resumed later. Of course, this brings with it all sorts of resource conflict issues, hence Python's infamous GIL - Global Interpreter Lock.

    Many thread implementations are actually more like coroutines.

提交回复
热议问题