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.
Copy code
import kotlinx.coroutines.*
fun main(): Unit = runBlocking {
val job = Job()
launch(job) {
delay(200)
}
job.join()
}
// Runs forever
👍🏽 1
n
Nick Allen
07/16/2021, 2:57 PM
launch
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.
e
ephemient
07/16/2021, 4:11 PM
the job you explicitly created isn't complete just because one child is complete. you can still launch another coroutine in it, for example.
l
louiscad
07/16/2021, 5:42 PM
You broke structured concurrency, that's why. Tip: don't inject jobs into coroutines manually to avoid that.
You probably want to use