blob: 15e126149b54dc1f4300ac76d9a6c8d6304d3706 [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 Liutikascd3cb312021-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.exampleBasic01
Roman Elizarov55a47f92017-01-24 10:21:31 +03007
Roman Elizarov0950dfa2018-07-13 10:33:25 +03008import kotlinx.coroutines.*
Roman Elizarov55a47f92017-01-24 10:21:31 +03009
Prendota65e6c8c2018-10-17 11:51:08 +030010fun main() {
Inego69c26df2019-04-21 14:51:25 +070011 GlobalScope.launch { // launch a new coroutine in background and continue
Roman Elizarov7cf452e2017-01-29 21:58:33 +030012 delay(1000L) // non-blocking delay for 1 second (default time unit is ms)
Roman Elizarov92ef15b2017-01-24 12:01:13 +030013 println("World!") // print after delay
Roman Elizarov55a47f92017-01-24 10:21:31 +030014 }
Roman Elizarova4d45d22017-11-20 16:47:09 +030015 println("Hello,") // main thread continues while coroutine is delayed
Roman Elizarov7cf452e2017-01-29 21:58:33 +030016 Thread.sleep(2000L) // block main thread for 2 seconds to keep JVM alive
Roman Elizarov92ef15b2017-01-24 12:01:13 +030017}