【发布时间】:2020-09-05 08:51:07
【问题描述】:
import kotlinx.coroutines.*
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()}")
}
kotlin 的文档
[main @coroutine#2] 我正在计算一个答案 [main @coroutine#3] 我正在计算另一个答案 [main @coroutine#1] 答案是 42
我的 Intellij IDEA 和 Android IDE
[main] 我正在计算一部分答案 [main] 我正在计算 另一个答案 [main] 答案是 42
如何显示"@coroutine#2","@coroutine#3","@coroutine#1"????
【问题讨论】:
标签: android-studio kotlin intellij-idea kotlin-coroutines