Kotlin's Job: A Handle to a Background Task

A Job is a handle to a coroutine, letting you manage its lifecycle. You get one from `launch` to control background tasks like network calls. The key footgun: a child's *failure* (Exception) cancels its parent, but a child's *cancellation* does not.
A Job is a handle to a coroutine, representing a cancellable background task with a lifecycle but no return value. You get one from the `launch` builder to manage side-effects like updating a UI or writing to a database. The main footgun is cancellation propagation: a child failing with an Exception cancels its parent, but a child being cancelled with `CancellationException` does not. This allows a parent to safely manage and cancel its children without cancelling itself. Use `SupervisorJob` to change this behavior.
Read the original → kotlinlang.org
- #kotlin
- #coroutines
- #concurrency
- #android
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.