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

Hunter

05/21/2018, 1:44 AM
I now know that you are not supposed to use runBlocking from inside coroutines, however I was writing some code with that mistake and found that it worked flawlessly on my OSX machine but failed fairly reliably on a Ubuntu server. Anyone know why that may be?
g

gildor

05/21/2018, 5:47 AM
Maybe because of different amount of available CPUs. runBlocking blocks thread of your CommonPool (which has
numCPUs + 1
threads), if you block all threads in CommonPool even non-blocking coroutine will wait for a thread to run. Anyway, maybe you could give more details what is exactly doesn’t work, maybe there is another reason. Actually runBlocking inside coroutines is similar to call of any other blocking function
l

louiscad

05/21/2018, 8:57 AM
You made a deadlock because the other machine had not enough threads available in CommonPool
9 Views