runBlocking {
System.err.println("runBlocking: 1")
lifecycleScope.launch {
System.err.println("runBlocking: 2")
delay(2000)
System.err.println("runBlocking: 3")
}
lifecycleScope.launch {
System.err.println("runBlocking: 4")
delay(1000)
System.err.println("runBlocking: 5")
}
delay(500)
System.err.println("runBlocking: 6")
}
System.err.println("runBlocking: 7")
输出结果:
2022-09-06 17:55:31.785 5540-5540/ W/System.err: runBlocking: 1
2022-09-06 17:55:31.786 5540-5540/ W/System.err: runBlocking: 2
2022-09-06 17:55:31.787 5540-5540/ W/System.err: runBlocking: 4
2022-09-06 17:55:32.287 5540-5540/ W/System.err: runBlocking: 6
2022-09-06 17:55:32.287 5540-5540/ W/System.err: runBlocking: 7
2022-09-06 17:55:32.787 5540-5540/ W/System.err: runBlocking: 5
2022-09-06 17:55:34.315 5540-5540/ W/System.err: runBlocking: 3