blob: 648cfec62e4955fa333a4eac0477585c36ab70f9 [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 Elizarovb3d55a52017-02-03 12:47:21 +03005// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
Roman Elizarova9687a32018-06-29 17:28:38 +03006package kotlinx.coroutines.experimental.guide.basic02
Roman Elizarov92ef15b2017-01-24 12:01:13 +03007
Roman Elizarov96695782017-10-01 10:48:15 -07008import kotlinx.coroutines.experimental.*
Roman Elizarov92ef15b2017-01-24 12:01:13 +03009
Roman Elizarova4d45d22017-11-20 16:47:09 +030010fun main(args: Array<String>) {
11 launch { // launch new coroutine in background and continue
Roman Elizarov7cf452e2017-01-29 21:58:33 +030012 delay(1000L)
13 println("World!")
Roman Elizarov92ef15b2017-01-24 12:01:13 +030014 }
Roman Elizarova4d45d22017-11-20 16:47:09 +030015 println("Hello,") // main thread continues here immediately
16 runBlocking { // but this expression blocks the main thread
17 delay(2000L) // ... while we delay for 2 seconds to keep JVM alive
18 }
Roman Elizarov92ef15b2017-01-24 12:01:13 +030019}