```runBlocking { val scopeJob = Job() val ...
# coroutines
s
Copy code
runBlocking {
    val scopeJob = Job()
    val scope = CoroutineScope(scopeJob)
    val job = scope.launch {
    }
}
I am unclear on whether
job
and
scopeJob
are the same. They seem to print different job ids.
job
is the Job returned from scope.launch construct in which I have passed a context which which has scopeJob assigned to it. So they should be the same?
b
job
is a child of
scopeJob
. If you do a printout of all child jobs of
scopeJob
, you'll see that
job
is part of it.
Copy code
runBlocking {
    val scopeJob = Job()
    val scope = CoroutineScope(scopeJob)
    val job = scope.launch {
    }
    scopeJob.children.forEach {
      println("Child: $it")
    }
    println("job $it")
}
If you were to cancel
scopeJob
,
job
would also be cancelled.
👍 1
👍🏽 1
💯 2
☝️ 2