sách gpt4 ai đã đi

Làm thế nào để hiển thị "@coroutine#2", "@coroutine#3", "@coroutine#1" trong coroutine Kotlin?

In lại 作者:行者123 更新时间:2023-12-02 13:16:24 28 4
mua khóa gpt4 Nike

import kotlinx.coroutines.*

fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")

fun main() = runBlocking {
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] 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和Android IDE

[main] I'm computing a piece of the answer [main] I'm computinganother piece of the answer [main] The answer is 42


如何显示“@ coroutine#2”,“@ coroutine#3”,“@ coroutine#1”?

1 Câu trả lời

Mở运行/调试配置窗口,然后将-Dkotlinx.coroutines.debugThêm vào VM选项ở giữa:
nhập mô tả hình ảnh ở đây
完成之后,您将获得以下输出:

[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

关于android-studio - 如何在kotlin coroutine中显示 “@coroutine#2” ,“@coroutine#3” ,“@coroutine#1”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63752105/

28 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com