kotlin 协程

CoroutineStart.DEFAULT调用时间是不固定的

多个协程调调用 每个自协程不是顺序调用

        Log.d("Corountines", "111")
        GlobalScope.launch(start = CoroutineStart.DEFAULT) {
            Log.d("Corountines", "222")
        }
        Log.d("Corountines", "333")
        GlobalScope.launch(start = CoroutineStart.DEFAULT) {
            Log.d("Corountines", "444")
        }
        Log.d("Corountines", "555")
        GlobalScope.launch(start = CoroutineStart.DEFAULT) {
            Log.d("Corountines", "666")
        } 
        Log.d("Corountines", "777")

会出现

Corountines: 1
Corountines: 2
Corountines: 3
Corountines: 4
Corountines: child_3
Corountines: child_1
Corountines: child_2

或者

1
2
3
child_1
child_3
child_2
4

你可能感兴趣的:(kotlin 协程)