【发布时间】:2018-11-11 16:48:15
【问题描述】:
如何在 IntelliJ IDEA 中启用 -Dkotlinx.coroutines.debug? 我有来自coroutines documentation 的以下代码:
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 选项呢?
【问题讨论】:
标签: intellij-idea kotlin jvm coroutine kotlinx.coroutines