Sobes.tech
Middle+

What is the difference between job and supervisor job in the context of working with Android?

sobes.tech AI

Answer from AI

Job is a common element of structured concurrency in Kotlin Coroutines. Cancel Job leads to the cancellation of all its child Jobs. Cancelling a child Job cancels the parent.

SupervisorJob is a special type of Job. Cancelling a child SupervisorJob does not cancel the parent or other child Jobs. It is useful for isolating errors in individual coroutines.

Comparison:

Attribute Job SupervisorJob
Cancelling child Cancels the parent Does not cancel the parent
Cancelling parent Cancels all child Jobs Cancels all child Jobs
Error isolation No Yes