如何在IntelliJ IDEA中启用-Dkotlinx.coroutines.debug?
我有来自协程文档的以下代码:
但实际上,我看到的只是普通的输出:
那么如何启用这个JVM选项?
fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
fun main() = runBlocking<Unit> {
val a = async {
log("I'm computing a piece of the answer")
6
}
val b = async {
log("I'm computing another piece of the answer")
7
}
log("The answer is ${a.await() * b.await()}")
}
我尝试在“运行 -> 编辑配置”中添加此选项:
但是根据文档,我期望看到以下输出:[main @coroutine#2] I'm computing a piece of the answer
[main @coroutine#3] I'm computing another piece of the answer
[main @coroutine#1] The answer is 42
但实际上,我看到的只是普通的输出:
[main] I'm computing a piece of the answer
[main] I'm computing another piece of the answer
[main] The answer is 42
那么如何启用这个JVM选项?