【发布时间】:2018-08-28 02:12:10
【问题描述】:
我正在使用 Mac OS 上的 IntelliJ IDEA 尝试使用 official guide 的 Kotlin 协程。在this 部分,建议使用-Dkotlinx.coroutines.debug JVM 选项来获取详细的日志输出。我所做的是我打开了“帮助/编辑自定义 VM 选项...”并在打开的 idea.vmoptions 文件中添加了-Dkotlinx.coroutines.debug 行。
idea.vmoptions编辑后的内容:
# custom IntelliJ IDEA VM options
-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Xverify:none
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-Dkotlinx.coroutines.debug
但是再次运行代码后,输出是:
[main] I'm computing a piece of the answer
[main] I'm computing another piece of the answer
[main] The answer is 42
Process finished with exit code 0
而预期的输出是:
[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
我在这里错过了什么?
【问题讨论】:
标签: intellij-idea kotlin kotlinx.coroutines