Kotlin Coroutine Mechanisms
summary
Coroutines are cheaper than threads: multiple coroutines run on one thread, suspend and resume across threads, and avoid heavy context switches; a thread-pool example shows wrong balances and ordering when mutable state is shared. Follow structured concurrency: parent waits for children and child never gets lost — use proper CoroutineScope/CoroutineContext, prefer supervisorScope/supervisorJob to isolate failures, use withContext(NonCancellable) for cleanup, and enable the kotlinx-coroutines-debug probe or IDE coroutine debugger to trace live coroutines.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:04Talk overview
- 3:53Developer journey with Kotlin coroutines
- 4:36Problems solved by coroutines
- 8:53Why threads are hard
- 9:58Thread cooperation and side effects
- 14:36Structured concurrency
- 18:32Parent waits for children
- 19:14Coroutine scope vs context
- 23:50Job vs scope hierarchy
- 25:33Debugging in IntelliJ IDEA
- 28:01Breaking structured concurrency
- 29:06Respecting structured concurrency
- 30:51Cancellation and timeout
- 32:12Unhandled exceptions
- 33:59Exception handling strategies
- 35:23Q&A








