Skip to content

Instantly share code, notes, and snippets.

@amanshuraikwar
Last active May 11, 2020 01:54
Show Gist options
  • Save amanshuraikwar/f8758c4923cd56a6df9dba7a0a909fb7 to your computer and use it in GitHub Desktop.
Save amanshuraikwar/f8758c4923cd56a6df9dba7a0a909fb7 to your computer and use it in GitHub Desktop.
Coroutines - runBlocking - GlobalScope - join()
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