Coroutines

  • A coroutine is similar to a thread in that:
    • It has its own stack
    • It is a line of execution
    • It has its own local variables
    • It has its own instruction pointer
  • A coroutine shares global variables
  • A set of coroutines in a program are collaborative:
    • Only one is running at a time
    • It suspends execution only when it explicitly requests to be suspended