问题
Is there an equivalent to JVM's Thread.sleep() in pure Kotlin for use on MPP projects? This could be implemented on each platform using expected
, but I am asking about a solution that does not use that method.
回答1:
This can be done using coroutines.
For example:
runBlocking {
println("Wait for 5sec")
delay(5000)
println("Done waiting for 5sec")
}
来源:https://stackoverflow.com/questions/55223336/how-to-make-a-delay-in-kotlin-multiplatform-pure-kotlin