So I was doing some tests with newSingleThreadCont...
# coroutines
w
So I was doing some tests with newSingleThreadContext and withContext and I was wondering, does withContext block the parent coroutineScope?
Copy code
import kotlinx.coroutines.*
fun main() = runBlocking {
    launch {
        delay(100)
        println("@ launch")
    }
    withContext(newSingleThreadContext("new Context")) {
        delay(200)
        println("@ withContext")
    }
    println("@ runBlocking")
}
// Outputs
@ launch
@ withContext
@ runBlocking
but
Copy code
import kotlinx.coroutines.*

fun main() = runBlocking {
    launch {
        delay(100)
        println("@ launch")
    }
    launch(newSingleThreadContext("new Context")) {
        delay(200)
        println("@ withContext")
    }
    println("@ runBlocking")
}
// Outputs
@ runBlocking
@ launch
@ withContext
could someone please explain this?
t
yes, that’s the point of
withContext
as opposed to
launch
a
withContext
suspends the coroutine until all of its children completes