tezvyn:

Explain the difference between launch and async in Kotlin Coroutines

Source: kotlinlang.orgbeginner

This tests scope behavior and side effects versus results. A strong answer says launch returns a Job for side effects, async returns a Deferred for results, and both are scope children. A red flag is using async for all tasks or ignoring exception handling.

This tests structured concurrency and the fire-and-forget versus result-bearing distinction. A strong answer explains that launch returns a Job for side effects with no returned value, while async returns a Deferred for results consumed via await. Both run concurrently inside their CoroutineScope and follow structured concurrency for cancellation and scope lifecycles. A red flag is treating async as a drop-in replacement for launch or claiming exceptions behave identically, since failures in async can propagate differently than in launch.

Read the original → kotlinlang.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Explain the difference between launch and async in Kotlin Coroutines · Tezvyn