// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. | |
package guide.context.example04 | |
import kotlinx.coroutines.experimental.* | |
fun log(msg: String) = println("[${Thread.currentThread().name}] $msg") | |
fun main(args: Array<String>) { | |
val ctx1 = newSingleThreadContext("Ctx1") | |
val ctx2 = newSingleThreadContext("Ctx2") | |
runBlocking(ctx1) { | |
log("Started in ctx1") | |
run(ctx2) { | |
log("Working in ctx2") | |
} | |
log("Back to ctx1") | |
} | |
} |