context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend CoroutineScope.() -> Unit
Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. The parent job is inherited from a CoroutineScope as well, but it can also be overridden with corresponding coroutineContext element.
By default, the coroutine is immediately scheduled for execution.
Other start options can be specified via
start parameter. See CoroutineStart for details.
An optional start parameter can be set to CoroutineStart.LAZY to start coroutine lazily. In this case,
the coroutine Job is created in new state. It can be explicitly started with start function
and will be started implicitly on the first invocation of join.
Uncaught exceptions in this coroutine cancel parent job in the context by default
(unless CoroutineExceptionHandler is explicitly specified), which means that when
launch is used with
the context of another coroutine, then any uncaught exception leads to the cancellation of parent coroutine.
See newCoroutineContext for a description of debugging facilities that are available for newly created coroutine.
context - additional to CoroutineScope.coroutineContext context of the coroutine.
start - coroutine start option. The default value is CoroutineStart.DEFAULT.
block - the coroutine code which will be invoked in the context of the provided scope.