Launches a new coroutine without blocking the current thread and returns a reference to the coroutine as aJob. The coroutine is cancelled when the resulting job iscancelled.
Uses thedefaultdispatcher.
The specificdispatcherProvider
instance to be used is determinedafter thecontext parameter has beenfolded into the receiver's context.
The selectedDispatcherProvider is essentially the first non-null result from:
thecontext parameter
the receiverCoroutineScope'scoroutineContext
DefaultDispatcherProvider.get Extracts theDispatcherProvider from theCoroutineScope receiver
import dispatch.core.launchDefaultimport dispatch.core.launchIOimport dispatch.core.launchMainimport dispatch.core.launchMainImmediateimport dispatch.core.launchUnconfinedimport dispatch.internal.test.Sample5import dispatch.internal.test.dispatcherNameimport dispatch.internal.test.someDispatcherProviderimport io.kotest.matchers.shouldBeimport kotlinx.coroutines.runBlockingfun main() { //sampleStart runBlocking(someDispatcherProvider) { dispatcherName() shouldBe "runBlocking thread" launchDefault { dispatcherName() shouldBe "default" }.join() } //sampleEnd}