Why it matters

OS threads don't scale to millions. Coroutines do. Modern async code is coroutine-based; understanding matters.

Advertisement

The architecture

Coroutine: function that can suspend and resume. On suspend, yields control to scheduler.

await: suspend until awaited value ready.

Coroutine executionCoroutinesuspend + resumeEvent loopschedule + dispatchasync I/Orelease + resumeMillions of coroutines feasible; blocking (sync) I/O in coroutine kills concurrency
Coroutine model.
Advertisement

How it works end to end

Cooperative: no preemption. Coroutine must explicitly yield (via await). Long blocking calls starve others.

Event loop: single thread runs multiple coroutines. Async I/O suspends coroutines while waiting for events.

Multi-thread with coroutines: Go goroutines are preemptible; Kotlin coroutines can dispatch across threads.