cmgurba
04/05/2019, 3:00 PMjob.cancel()
from this snippet in the coroutine docs, why does playground time out entirely? fun main() = runBlocking {
//sampleStart
val job = launch {
repeat(1000) { i ->
println("I'm sleeping $i ...")
delay(500L)
}
}
delay(1300L) // delay a bit
println("main: I'm tired of waiting!")
job.cancel() // cancels the job
job.join() // waits for job's completion
println("main: Now I can quit.")
//sampleEnd
}
louiscad
04/05/2019, 3:01 PMrunBlocking
waits for all children coroutines to completecmgurba
04/05/2019, 3:01 PMlouiscad
04/05/2019, 3:02 PMcmgurba
04/05/2019, 3:02 PMlouiscad
04/05/2019, 3:02 PM