文档中的协程示例不起作用

时间:2019-05-09 09:42:40

标签: kotlin coroutine

我开始学习协程,并尝试运行示例structured-concurrency中的代码。但是我得到了另一个结果。如果设置为delay(1000L) “ Hellow,则仅打印” Process finished with exit code -1073741819 (0xC0000005)。但是,如果我设置delay(100L),则会得到 “你好,世界!” 。为什么launch{}阻止无法启动?

import kotlinx.coroutines.*

fun main() = runBlocking { // this: CoroutineScope
    launch { // launch a new coroutine in the scope of runBlocking
        delay(100L)
        println("World!")
    }
    println("Hello,")
}

screen 1   screen 2

1 个答案:

答案 0 :(得分:0)

好的,我禁用了程序“ Punto switcher”,现在所有程序都能正常工作。

相关问题