Skip to content

Instantly share code, notes, and snippets.

@mohak1712
Created November 19, 2018 05:49
Show Gist options
  • Save mohak1712/cb6a1ac6b1567c13731cfe79bd83ef8f to your computer and use it in GitHub Desktop.
Save mohak1712/cb6a1ac6b1567c13731cfe79bd83ef8f to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
button.setOnClickListener {
GlobalScope.launch(context = Dispatchers.Main) {
println("launched coroutine 1")
delay(5000)
println("Here after a delay of 5 seconds")
}
GlobalScope.launch(context = Dispatchers.Main) {
println("launched coroutine 2")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment