tezvyn:

Explain launch vs. async in Kotlin Coroutines

Source: kotlinlang.orgbeginner

Tests your grasp of structured concurrency, return values, and exceptions. `launch` is for fire-and-forget tasks (returns `Job`), while `async` is for tasks that produce a result (returns `Deferred`).

This question tests your grasp of structured concurrency fundamentals, specifically how coroutine builders manage return values and exceptions. A strong answer differentiates `launch` (fire-and-forget, returns `Job`) from `async` (returns a value via `Deferred<T>`). Use `launch` for side effects and `async` for parallel work where you combine results via `.await()`. A common red flag is treating `async` like a simple background thread without explaining how `.await()` retrieves the result and propagates exceptions.

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 launch vs. async in Kotlin Coroutines · Tezvyn