Structured Concurrency & Cancellation
KOTLIN › Concurrency
Drills coroutine scoping, failure isolation, cooperative cancellation, and parallel async/await decomposition.
Structured concurrency is the backbone of correct coroutine code on Android, so interviewers probe whether you understand how scopes bound lifetimes, how failures and cancellation propagate, and when each is isolated. Expect to reason about coroutineScope vs supervisorScope, why cancellation is cooperative, and exactly when a CoroutineExceptionHandler does or does not fire. Strong answers connect these rules to real ViewModel/repository patterns rather than reciting API names.
What this covers
- Structured concurrency guarantees: scopes bound child lifetimes, parents wait for children, cancellation/failure propagate by the rules
- coroutineScope vs supervisorScope and Job vs SupervisorJob for failure isolation between siblings
- Cooperative cancellation with isActive, ensureActive(), and yield(), and why CancellationException must be rethrown
- Exception handling: try/catch around suspending calls vs CoroutineExceptionHandler, and where each actually works
- launch vs async exception propagation, including async exposing failures through await()
- Parallel decomposition with async/await and cleanup with finally / NonCancellable / withTimeout
Study this topic
- Structured Concurrency & Cancellation explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Structured Concurrency & Cancellation interview questions and answers