I'm trying to understand the difference between the 2.
If a CoroutineScope is not tied to any lifecycle-aware component, then I think they behave the same:
If Im not passing any context to CoroutineScope, then both would initialized with EmptyCoroutineContext, and thats practicaly means children has no parents, meaning they run totaly independently, and not even scope.cancel() actualy cancels them, and thats only happen when the whole app is closed. Am I missing something here ?
val scope = GlobalScope()
scope.launch {
launch {
println("job1 working")
}
launch {
println("job2 working")
}
}
scope.cancel() // no any effect
val scope = CoroutineScope(EmptyCoroutineContext)
...
scope.cancel()
If my understanding is correct, are there any example where they different ?