I try to understand how parent - child relationship works in that case
private fun coroutineTest() {
val job = CoroutineScope(Dispatchers.IO).launch {
val standAloneJob = Job(coroutineContext.job)//this will create the relationship parent - child
launch(standAloneJob) {
delay(2000)
Log.d(TAG,"I'm here")
}
delay(4000)
if(standAloneJob.isCompleted) { // always false
Log.d(TAG,"isCompleted")
}
//standAloneJob.complete() // without this line method invokeOnCompletion never called
}
job.invokeOnCompletion {
Log.d(TAG,"invokeOnCompletion")
}
}
The question is why child coroutine initialized by standAloneJob never completed and as a consequence parent coroutine not completed too?