Kotlin Coroutine Mechanisms
summary
Playful live examples demonstrate concrete behaviors: runBlocking hijacks the current thread so it blocks main, launch is fire-and-forget (returns a Job) and join suspends until completion, and async returns a Deferred whose await yields the result. Shows a crashing LiveData update on a background thread that is fixed with withContext(Dispatchers.Main). Recommends logging and the KotlinX coroutines debug VM flag. Explains dispatchers: default uses a shared thread pool sized to CPU cores (>=2), IO shares those threads (up to many), and viewModelScope is lifecycle‑aware on Main.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:25Playground setup
- 3:14runBlocking behavior
- 5:00launch coroutine builder
- 9:40Modifying task execution
- 13:34Execution order with join
- 16:11async and deferred results
- 21:26Coroutine context and dispatchers
- 26:01ViewModelScope vs custom scopes
- 30:15Dispatchers IO and Main
- 31:42Fixing UI updates
- 33:06Resources and closing








