← Kotlin Programming learning pathKotlin Programming · Module 9 of 10
Coroutines
Write asynchronous code that looks sequential.
📖 Key ideas
- Coroutines are lightweight threads managed by Kotlin.
- suspend functions can pause without blocking.
- Builders: launch (fire and forget), async (returns Deferred).
- Dispatchers: Main, IO, Default.
- 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