What is a Coroutine?

The word “coroutine” is composed of two words: “co” (cooperative) and “routines” (functions).

Coroutines are functions that are cooperative.

How are functions non-cooperative?

Usually, when a function calls a second function, the first cannot continue until the second function finishes and returns to where it was called.

The control remains with the second function until it executes completely and only then can the control return to the first one.

svg viewer