As asked
Explain structured concurrency in Kotlin coroutines. How does it change the way you launch background work in an Android or JVM service?
Sample answer outline
Structured concurrency means child coroutines are tied to an explicit parent scope, so cancellation, failure and lifetime are visible in the call structure. In Android this usually means using lifecycle-aware scopes such as viewModelScope rather than GlobalScope. In backend services it means request-scoped or application-scoped CoroutineScope objects with clear shutdown behaviour. A failed child should either cancel siblings or be isolated with SupervisorJob when that is intentional. Candidates trip up by launching fire-and-forget work that outlives the user action, leaks resources, or silently drops exceptions.
Expect these follow-ups
- When would you use supervisorScope instead of coroutineScope?
- How do Dispatchers.IO and Dispatchers.Default differ?
- What happens to child coroutines when a ViewModel is cleared?