Overview - SupervisorJob for independent failure
What is it?
SupervisorJob is a special kind of job in Kotlin coroutines that lets child tasks run independently. If one child fails, it does not cancel its siblings or the parent job. This helps manage multiple tasks where failure in one should not stop others. It is part of structured concurrency to control how coroutines behave together.
Why it matters
Without SupervisorJob, if one child coroutine fails, it cancels all sibling coroutines and the parent, which can cause unwanted stops in your app or service. SupervisorJob solves this by isolating failures, so one task crashing doesn't bring down others. This makes your programs more robust and responsive, especially when handling multiple independent tasks.
Where it fits
Before learning SupervisorJob, you should understand basic Kotlin coroutines, Job, and CoroutineScope. After this, you can explore advanced coroutine error handling, CoroutineExceptionHandler, and structured concurrency patterns for building resilient asynchronous programs.