Hello there, I am following the Kotlin coroutines ...
# coroutines
n
Hello there, I am following the Kotlin coroutines documentation and I am at the chapter of "Confined vs unconfined dispatcher": https://kotlinlang.org/docs/reference/coroutines/coroutine-context-and-dispatchers.html#unconfined-vs-confined-dispatcher I copy pasted the first sample code into Try kotlin website and I don't get the same result as described in the documentation:
Copy code
launch(Dispatchers.Unconfined) { // not confined -- will work with main thread
        println("Unconfined      : I'm working in thread ${Thread.currentThread().name}")
        delay(500)
        println("Unconfined      : After delay in thread ${Thread.currentThread().name}")
    }
    launch { // context of the parent, main runBlocking coroutine
        println("main runBlocking: I'm working in thread ${Thread.currentThread().name}")
        delay(1000)
        println("main runBlocking: After delay in thread ${Thread.currentThread().name}")
    }
I get:
Copy code
Unconfined      : I'm working in thread main @coroutine#2
main runBlocking: I'm working in thread main @coroutine#3
Unconfined      : After delay in thread kotlinx.coroutines.DefaultExecutor @coroutine#2
main runBlocking: After delay in thread main @coroutine#3
Instead of:
Copy code
Unconfined      : I'm working in thread main
main runBlocking: I'm working in thread main
Unconfined      : After delay in thread kotlinx.coroutines.DefaultExecutor
main runBlocking: After delay in thread main
Any idea why ?
I guess I read it too quickly I assumed
@coroutine#2
was a different thread than the main one
All good, nevermind
b
Yeah, it’s just some additional debugging output