← Kotlin Programming learning path
Kotlin Programming · Module 9 of 10

Coroutines

Write asynchronous code that looks sequential.

📖 Key ideas

  1. Coroutines are lightweight threads managed by Kotlin.
  2. suspend functions can pause without blocking.
  3. Builders: launch (fire and forget), async (returns Deferred).
  4. Dispatchers: Main, IO, Default.
  5. Flow emits multiple values over time.
💡 Real-life example: Coroutines are a juggler handling many balls by pausing each in the air rather than holding them.
CoroutineLightweight concurrent task
launchStarts a coroutine without result
async/awaitStarts and awaits a result
FlowCold asynchronous stream