Why it matters

Coroutines simplify async. Understanding shapes modern JVM.

Advertisement

The architecture

suspend function or virtual thread.

Blocking looks blocking; scheduler swaps.

Structured concurrency.

Coroutine agent stackSequential codelooks blockingRuntime yieldson I/OStructured scopepropagates cancelKotlin coroutines for Kotlin; Java 21+ virtual threads for pure Java
Coroutine.
Advertisement

How it works end to end

Kotlin: suspend + coroutineScope.

Java 21+: Thread.ofVirtual.

Structured concurrency scopes.

Cancel propagation.