Skip to content

Instantly share code, notes, and snippets.

@KhomDrake
Created January 30, 2022 16:53
Show Gist options
  • Save KhomDrake/b807527f4c6d7bee334039a3cfbf8910 to your computer and use it in GitHub Desktop.
Save KhomDrake/b807527f4c6d7bee334039a3cfbf8910 to your computer and use it in GitHub Desktop.
Coroutines Example 2
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
fun main(args: Array<String>) {
GlobalScope.launch {
delay(1000L)
println("World!")
printThread()
}
printThread()
println("Hello,")
Thread.sleep(2000)
}
private fun printThread() {
println("In Thread ${Thread.currentThread()}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment