blob: d1ec85fa9b88b6fae326fa963f2e0a9a32b73714 [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
Roman Elizarovdb0ef0c2019-07-03 15:02:44 +03002 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarovf16fd272017-02-07 11:26:00 +03003 */
4
Roman Elizarov2f6d7c92017-02-03 15:16:07 +03005// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
Roman Elizarov0950dfa2018-07-13 10:33:25 +03006package kotlinx.coroutines.guide.context02
Roman Elizarov2f6d7c92017-02-03 15:16:07 +03007
Roman Elizarov0950dfa2018-07-13 10:33:25 +03008import kotlinx.coroutines.*
Roman Elizarov2f6d7c92017-02-03 15:16:07 +03009
Prendota65e6c8c2018-10-17 11:51:08 +030010fun main() = runBlocking<Unit> {
Roman Elizarovdc29b072018-09-11 18:42:03 +030011 launch(Dispatchers.Unconfined) { // not confined -- will work with main thread
Roman Elizarovc32579e2018-09-09 19:21:43 +030012 println("Unconfined : I'm working in thread ${Thread.currentThread().name}")
Roman Elizarovd0021622017-03-10 15:43:38 +030013 delay(500)
Roman Elizarovc32579e2018-09-09 19:21:43 +030014 println("Unconfined : After delay in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030015 }
Roman Elizarovc32579e2018-09-09 19:21:43 +030016 launch { // context of the parent, main runBlocking coroutine
17 println("main runBlocking: I'm working in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030018 delay(1000)
Roman Elizarovc32579e2018-09-09 19:21:43 +030019 println("main runBlocking: After delay in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030020 }
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030021}