Roman Elizarov | 3754f95 | 2017-01-18 20:47:54 +0300 | [diff] [blame^] | 1 | package examples |
2 | |||||
3 | import kotlinx.coroutines.experimental.newSingleThreadContext | ||||
4 | import kotlinx.coroutines.experimental.run | ||||
5 | import kotlinx.coroutines.experimental.runBlocking | ||||
6 | |||||
7 | fun main(args: Array<String>) { | ||||
8 | val ctx1 = newSingleThreadContext("Ctx1") | ||||
9 | val ctx2 = newSingleThreadContext("Ctx2") | ||||
10 | runBlocking(ctx1) { | ||||
11 | log("Started in ctx1") | ||||
12 | run(ctx2) { | ||||
13 | log("Working in ctx2") | ||||
14 | } | ||||
15 | log("Back to ctx1") | ||||
16 | } | ||||
17 | } |