1 /*
<lambda>null2  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 // This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleContext04
7 
8 import kotlinx.coroutines.*
9 
10 fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
11 
12 fun main() {
13     newSingleThreadContext("Ctx1").use { ctx1 ->
14         newSingleThreadContext("Ctx2").use { ctx2 ->
15             runBlocking(ctx1) {
16                 log("Started in ctx1")
17                 withContext(ctx2) {
18                     log("Working in ctx2")
19                 }
20                 log("Back to ctx1")
21             }
22         }
23     }
24 }
25