If you are learning Kotlin coroutines, you might have stumbled upon the term Continuation. At first, it looks scary and complicated, but don’t worry — by the end of this blog, you’ll clearly understand what continuation in coroutine is, how it works internally, and why interviewers love to ask questions about it.
What is Continuation in Coroutine?
In simple words:
- A Continuation is like a bookmark in a coroutine.
- When a coroutine is suspended, Kotlin needs a way to remember where it stopped and what to do when it resumes.
- This “memory of where to continue” is stored inside a Continuation object.
👉 Think of it like pausing a YouTube video. The Continuation remembers the timestamp and what you were watching, so when you hit play again, it resumes from the exact point.
Internal of Continuation in Coroutine
Let’s break it down step by step:
- Coroutine suspension:
When you call a suspending function (likedelay()), the coroutine doesn’t block the thread. Instead, it suspends execution. - Continuation object is created:
At this point, Kotlin creates a Continuation object which stores:- The current state (where execution paused).
- The local variables at that point.
- A callback (
resume()orresumeWithException()) to continue execution later.
- Resuming with continuation:
When the suspending operation (likedelay) is complete, the Continuation is triggered, and the coroutine resumes right where it left off.
A Simple Example
suspend fun demo() {
println("Step 1")
delay(1000) // coroutine suspends here
println("Step 2")
}
What happens here internally?
- At
delay(1000), coroutine suspends. - A Continuation object is created holding the info:
- Next line to execute (
println("Step 2")) - Variables, state, and execution context.
- Next line to execute (
- After 1 second,
Continuation.resume()is called. - Execution continues from Step 2.
Why Continuation is Important?
- It makes coroutines lightweight and non-blocking.
- It allows Kotlin to handle millions of coroutines without blocking threads.
- It is the core internal building block of coroutines.
Without Continuation, suspension and resumption in coroutines would not be possible.
Quick Summary
- Continuation = Bookmark of coroutine’s state.
- It stores where to resume, variables, and execution flow.
- Every suspending function under the hood uses Continuation.
Common Continuation in Coroutine Interview Questions
1. What is Continuation in Coroutine?
Answer:
Continuation is an internal mechanism in Kotlin coroutines that stores the state of a suspended coroutine. It keeps track of where the coroutine paused and how it should resume later. Each suspending function is compiled into code that takes an extra parameter of type Continuation<T>, which is used to resume execution when the suspension completes.
👉 Interview Tip: Always explain it with a real-world analogy (like pausing and resuming a video) to make your answer clear.
2. How does Continuation work internally in Kotlin Coroutines?
Answer:
When a coroutine is suspended, the compiler generates a Continuation object that holds:
- The next instruction to run after resumption.
- The local variables at suspension point.
- The execution context (like dispatcher).
When the async operation finishes, Kotlin calls resume() or resumeWithException() on this Continuation. This brings the coroutine back to life exactly where it left off.

👉 Interview Tip: Use keywords like “state machine” and “resume mechanism” to impress the interviewer with technical depth.
✅ Now you know:
- What Continuation in Coroutine is
- How it works internally
- How to explain it in interviews

