Skip to content

Instantly share code, notes, and snippets.

@mohak1712
Last active November 19, 2018 06:04
Show Gist options
  • Save mohak1712/2eb587a859411c83bf47711f56aad410 to your computer and use it in GitHub Desktop.
Save mohak1712/2eb587a859411c83bf47711f56aad410 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")
Thread.sleep(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