Coroutines Basics
KOTLIN › Coroutines
How suspend, builders, jobs, and scopes run async work without blocking threads.
Coroutines are the default concurrency model on modern Android, so interviewers probe whether you truly understand suspension versus blocking rather than just memorizing API names. Expect to explain what suspend compiles to, the difference between launch and async, and how a Job models the lifetime of running work. Strong answers connect these primitives to structured concurrency and know when a coroutine is the wrong tool.
What this covers
- What suspend actually does: pauses the coroutine without blocking the thread, via compiler CPS transformation
- A suspend function is not a coroutine: it has no Job and runs inside whoever called it
- Coroutine builders (launch, async, runBlocking, coroutineScope) and what each one is for
- launch returns a Job (fire-and-forget); async returns a Deferred whose await() retrieves the result
- The six Job states, and why a cancelled job reports isCompleted true while a cancelling one does not
- join() waits for completion and never throws; await() waits for a result and rethrows the failure
- async only buys concurrency if both are started before either is awaited
- CoroutineScope, structured concurrency, and how scope cancellation propagates to children
- GlobalScope has no lifetime: use an injected application scope, or WorkManager for process death
- When NOT to use coroutines: pure computation and already-on-the-right-thread work
Study this topic
- Coroutines Basics explained: the guided lesson
- 16 practice quiz questions
- Coroutines Basics interview questions and answers