涛哥,
fun main() {
runBlocking {
launch {
delay(2000)
println("hello")
}
coroutineScope {
launch {
delay(3000)
println("coroutineScope launch")
}
delay(1000)
println("coroutineScope")
}
println("world")
}
}
这个的输出顺序是:
coroutineScope
hello
coroutineScope launch
world
我的问题是,我为什么“world”最后输出,而不是第一个输出
展开
作者回复: runblock会阻塞当前协程,会首先执行这里面的内容