fun SupervisorJob(parent: Job? = null): CompletableJob

Creates a supervisor job object in an active state. Children of a supervisor job can fail independently of each other.

A failure or cancellation of a child does not cause the supervisor job to fail and does not affect its other children, so a supervisor can implement a custom policy for handling failures of its children:

If parent job is specified, then this supervisor job becomes a child job of its parent and is cancelled when its parent fails or is cancelled. All this supervisor's children are cancelled in this case, too. The invocation of cancel with exception (other than CancellationException) on this supervisor job also cancels parent.



an optional parent job.


Link copied to clipboard