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

Creates a job object in an active state. A failure of any child of this job immediately causes this job to fail, too, and cancels the rest of its children.

To handle children failure independently of each other use SupervisorJob.

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

Conceptually, the resulting job works in the same way as the job created by the launch { body } invocation (see launch), but without any code in the body. It is active until cancelled or completed. Invocation of CompletableJob.complete or CompletableJob.completeExceptionally corresponds to the successful or failed completion of the body of the coroutine.



an optional parent job.


Link copied to clipboard