blob: a1b5bc5f2318a1df9e4240c0ff41038eb7c92e7e [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
Roman Elizarov660c2d72020-02-14 13:18:37 +03002 * Copyright 2016-2020 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
Aurimas Liutikasaf4ee622021-05-12 21:56:16 +00005// This file was automatically generated from basics.md by Knit tool. Do not edit.
Roman Elizarov660c2d72020-02-14 13:18:37 +03006package kotlinx.coroutines.guide.exampleBasic06
Roman Elizarovb3d55a52017-02-03 12:47:21 +03007
Roman Elizarov0950dfa2018-07-13 10:33:25 +03008import kotlinx.coroutines.*
Roman Elizarovb3d55a52017-02-03 12:47:21 +03009
Roman Elizarov660c2d72020-02-14 13:18:37 +030010fun main() = runBlocking { // this: CoroutineScope
11 launch {
12 delay(200L)
13 println("Task from runBlocking")
Roman Elizarovb3d55a52017-02-03 12:47:21 +030014 }
Roman Elizarov660c2d72020-02-14 13:18:37 +030015
16 coroutineScope { // Creates a coroutine scope
17 launch {
18 delay(500L)
19 println("Task from nested launch")
20 }
21
22 delay(100L)
23 println("Task from coroutine scope") // This line will be printed before the nested launch
24 }
25
26 println("Coroutine scope is over") // This line is not printed until the nested launch completes
Roman Elizarovb3d55a52017-02-03 12:47:21 +030027}