Skip to content

Instantly share code, notes, and snippets.

View makzimi's full-sized avatar

Maxim Kachinkin makzimi

View GitHub Profile
@makzimi
makzimi / runBlockingWithSingleThreadDispatcher.kt
Last active January 13, 2021 15:59
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!")
}
}
@makzimi
makzimi / runBlockingInUIThread.kt
Last active January 13, 2021 16:00
Example of how runBlocking can deadlock Android app if run on UI thread.
runBlocking(Dispatchers.Main) {
println("Hello, World!")
}