【发布时间】:2020-03-08 23:49:06
【问题描述】:
如何在 kotlin 中像多线程一样进行多次启动
我想让first second 永远在同一时间工作!!
喜欢这段代码...
runBlocking {
// first
launch{
first()
}
// second
launch{
second()
}
}
suspend fun first(){
// do something
delay(1000L)
// Recursive call
first()
}
suspend fun second(){
// do something
delay(1000L)
// Recursive call
second()
}
【问题讨论】:
标签: kotlin coroutine kotlin-coroutines