Last active
May 11, 2020 01:54
-
-
Save amanshuraikwar/f8758c4923cd56a6df9dba7a0a909fb7 to your computer and use it in GitHub Desktop.
Coroutines - runBlocking - GlobalScope - join()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.* | |
fun main() = runBlocking { | |
val job = GlobalScope.launch { // launch a new coroutine and keep a reference to its Job | |
delay(1000L) | |
println("World!") | |
} | |
println("Hello,") | |
job.join() // wait until child coroutine completes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment