Icyrockton
01/25/2024, 11:51 AMresume
is on another thread?
suspend fun a() { println("call a") }
suspend fun b() { println("call b") }
val executor = Executors.newSingleThreadScheduledExecutor()
suspend fun test() {
println(Thread.currentThread().name)
a()
val g = suspendCoroutine<Int> { continuation ->
executor.schedule({
println("call resume!!! ${Thread.currentThread().name}")
continuation.resume(20)
}, 1, TimeUnit.SECONDS)
COROUTINE_SUSPENDED
}
println(g)
b()
}
suspend fun main() {
test()
println("test done!")
}
Sam
01/25/2024, 11:59 AMexecutor.shutdown()
once all your tasks are submitted.Sam
01/25/2024, 12:00 PMCOROUTINE_SUSPENDED
doing in there? That looks like an internal symbol that doesn't belong in ordinary code like this.Icyrockton
01/25/2024, 12:02 PM