Sitemap

Member-only story

Thinking in Continuations: How Suspend Really Works in Kotlin

A deep dive into the Continuation interface, compiler‑generated state machines, and what actually happens when a coroutine suspends.

6 min readJun 6, 2026

--

Press enter or click to view image in full size

If you’ve been using coroutines for a while, you probably feel comfortable with launch, async, dispatchers and structured concurrency. But under the surface, all of that suspend magic boils down to one simple idea: continuation.

In this article, I’ll walk through the Continuation interface, how the Kotlin compiler rewrites suspend functions into state machines, and how those pieces fit together at runtime.

Quick recap: what suspend actually does

When you mark a function with suspend keyword, you’re telling the compiler:

This function might pause and resume later, but from the caller’s perspective it should look like a normal call returning T.

A few important properties:

  • A suspend fun can pause at suspension points (like delay, await) without blocking the thread.
  • When it resumes, it continues as if it had never left; locals and the position in the function are restored.
  • Callers can chain suspend…

--

--