Skip to content

Instantly share code, notes, and snippets.

@makzimi
Last active January 13, 2021 15:59
Show Gist options
  • Save makzimi/a7935ec1ea73a92c9d5dca25d3b81827 to your computer and use it in GitHub Desktop.
Save makzimi/a7935ec1ea73a92c9d5dca25d3b81827 to your computer and use it in GitHub Desktop.
Example of how runBlocking can make a deadlock with single thread dispatcher.
val singleThreadDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
GlobalScope.launch(singleThreadDispatcher) {
runBlocking(singleThreadDispatcher) {
println("Hello, World!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment