blob: 038102d309ecd591e089914895ac8f0cd9382c29 [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03002 * Copyright 2016-2018 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.*
9import kotlin.coroutines.*
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030010
11fun main(args: Array<String>) = runBlocking<Unit> {
Roman Elizarovdc29b072018-09-11 18:42:03 +030012 launch(Dispatchers.Unconfined) { // not confined -- will work with main thread
Roman Elizarovc32579e2018-09-09 19:21:43 +030013 println("Unconfined : I'm working in thread ${Thread.currentThread().name}")
Roman Elizarovd0021622017-03-10 15:43:38 +030014 delay(500)
Roman Elizarovc32579e2018-09-09 19:21:43 +030015 println("Unconfined : After delay in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030016 }
Roman Elizarovc32579e2018-09-09 19:21:43 +030017 launch { // context of the parent, main runBlocking coroutine
18 println("main runBlocking: I'm working in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030019 delay(1000)
Roman Elizarovc32579e2018-09-09 19:21:43 +030020 println("main runBlocking: After delay in thread ${Thread.currentThread().name}")
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030021 }
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030022}