Intermediate 9 min readKotlin 2.0
Kotlin launch vs async — Jobs and Deferred Results
launch and async both start coroutines, but they serve different purposes. Pick launch when you do not need a return value; use async when you do.
What You Will Learn
- Start work with launch (returns Job)
- Compute results with async (returns Deferred)
- Retrieve results using await()
- Run multiple async tasks concurrently
- Cancel work via Job
launch — Fire and Forget
launch starts a coroutine and returns a Job. Use it for side effects like logging, UI updates, or background sync when you do not need the result in the caller.
launch Example
kotlin
import kotlinx.coroutines.*
fun main() = runBlocking {
val job = launch {
delay(200)
println("Work finished")
}
println("Started job: ${job.isActive}")
job.join()
}Output
Started job: true
Work finished
job.join() waits for the launched coroutine to complete. isActive is true while it runs.
Dependency required:
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")async and await — Get a Result
async returns Deferred<T>. Call await() to suspend until the result is ready. Multiple async blocks can run in parallel.
Parallel async
kotlin
import kotlinx.coroutines.*
suspend fun fetch(id: Int): Int {
delay(100)
return id * 10
}
fun main() = runBlocking {
val a = async { fetch(1) }
val b = async { fetch(2) }
println(a.await() + b.await())
}Output
30
Both fetch calls run concurrently. await() retrieves 10 and 20, then they are summed.
Practice Exercise
Exercisepredict output
What does this print? import kotlinx.coroutines.* fun main() = runBlocking { val d = async { 5 + 5 } println(d.await()) }
Quick Quiz
Quick Quiz
When should you prefer async over launch?
Frequently Asked Questions
Related Tutorials
Last updated: 2026-05-19Kotlin 2.0
Written by KotlinGuide Editorial Team · Reviewed by KotlinGuide Technical Review