What is a coroutine?

前端 未结 10 1982
闹比i
闹比i 2020-11-28 17:27

What is a coroutine? How are they related to concurrency?

10条回答
  •  甜味超标
    2020-11-28 18:00

    Coroutine is similar to subroutine/threads. The difference is once a caller invoked a subroutine/threads, it will never return back to the caller function. But a coroutine can return back to the caller after executing a few piece of code allowing the caller to execute some of its own code and get back to the coroutine point where it stopped execution and continue from there. ie. A coroutine has more than one entry and exit points

提交回复
热议问题