Slide 11
Slide 11 text
An Example
Coroutine context in purple
import kotlinx.coroutines.*
fun CoroutineScope.working(){
println("I'm working in thread ${Thread.currentThread().name}")
}
fun main() = runBlocking {
launch {
working()
}
launch(Dispatchers.Unconfined) {
working()
}
launch(Dispatchers.Default) {
working()
}
launch(CoroutineName("MyOwnThread")) {
working()
}
}
I'm working in thread main @coroutine#3
I'm working in thread DefaultDispatcher-worker-1 @coroutine#4
I'm working in thread main @coroutine#2 I'm working in thread main
@MyOwnThread#5
09