The follow code will never end, and if forcefully ...
# coroutines
The follow code will never end, and if forcefully stopped the dump lists no coroutines. I have a workaround but I was wondering if this is a bug or just how it's supposed to be? It feels counterintuitive.
Copy code
runBlocking {
	fun tt(s: CoroutineScope) = s.launch(start = CoroutineStart.LAZY) { }
	val s = this
well, if you never start the job, it won't ever finish, so runBlocking can't return. seems logical to me
đź‘Ť 1
I don't recall how the dump works, but I think it only reports active coroutines, which an unstarted one isn't yet. the job is attached to the parent, but the coroutine hasn't begun execution
can only finish if all its child-Coroutines have finished (Structured Concurrency). The CoroutineScope provided by the runBlocking never ends/finishes since one of its child-Coroutines (s.launch) never finishes. Therefore the call to runBlocking never returns, since it only will return after its CoroutineScope ends.
Mmh, I assumed that “can only finish if all its child-coroutines have finished” meant it called .join() on all its children.
It's effectively the same thing except it doesn't manipulate the life-cycle of the children (so it won't start jobs that are still new, but not started)
Ok thanks