https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

vineethraj49

03/24/2021, 12:24 PM
if all my
Dispatchers.Default
threads (
Runtime.getRuntime().availableProcessors()
) are blocked under
runBlocking
, a
GlobalScope.future(<http://Dispatcher.IO|Dispatcher.IO>)
also fails to launch; why is this the case?
c

Casey Brooks

03/24/2021, 2:52 PM
If all CPU cores are tied up, there’s literally no compute resources left to spawn IO threads. Dispatchers.IO threads are still running on the same physical hardware that Dispatchers.Default are, even if the thread pools are different
u

uli

03/24/2021, 3:13 PM
@Casey Brooks, the cores are probably idle. Only the thread are blocked. @vineethraj49 runBlocking is not allowed inside a coroutine.
This function should not be used from a coroutine. It is designed to bridge regular blocking code to libraries that are written in suspending style, to be used in main functions and in tests.
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html
3 Views