marcinmoskala
07/16/2021, 2:51 PMJob::join
does not resume when coroutine is just done? The documentation suggests that it should, but I cannot make in resume any other way but by crashing or cancelling a coroutine.
import kotlinx.coroutines.*
fun main(): Unit = runBlocking {
val job = Job()
launch(job) {
delay(200)
}
job.join()
}
// Runs forever
Nick Allen
07/16/2021, 2:57 PMlaunch
creates a new child Job
, which it gives you as the return value. The child Job
is finishing but the parent that you create explicitly is never finishing. Try just joining on the Job
that launch
returns or call complete
on the Job
you created.ephemient
07/16/2021, 4:11 PMlouiscad
07/16/2021, 5:42 PMcoroutineScope { }
or call join()
on the Job
instance returned by the launch { }
call.marcinmoskala
07/17/2021, 8:18 AM