Vivek Sharma
01/27/2021, 4:59 PMJob from coroutine scope
is printed first, not Job1
, why is that?
fun main() = runBlocking<Unit> {
launch {
println("Job 1")
}
launch {
println("Job 2")
}
launch {
println("Job 3")
}
coroutineScope {
launch {
println("Job from launch inside coroutine scope")
}
println("Job from coroutine scope ")
}
}
Zach Klippenstein (he/him) [MOD]
01/27/2021, 5:02 PMlaunch
enqueues the coroutine to start, and then returns. If you pass start = UNDISPATCHED
to launch
then the inside one will print first.