https://kotlinlang.org logo
Title
g

Grantas33

05/18/2021, 10:27 PM
using launch(Dispatcher.Default) {..} on a single core machine causes a deadlock (app idles forever), is this expected? It would be nice to get some runtime exception
b

Brian Dilley

05/18/2021, 10:48 PM
where did you find a single core machine?
😁 3
g

Grantas33

05/18/2021, 10:57 PM
cheapest machines of major cloud service providers have a single core
t

Tijl

05/19/2021, 6:44 AM
are you sure it’s the launch? you’re not using
runBlocking
somewhere for example?
g

Grantas33

05/19/2021, 8:34 AM
I use runBlocking to start a new coroutine from a non-suspend function (main program entry function)
runBlocking {
        launch(Dispatchers.Default) {
...
Is there a better way?
by the way, using Dispatchers.Unconfined works fine
t

Tijl

05/19/2021, 10:37 AM
if the thread you call it from in not in the pool for Default (the main thread should be) that is fine. But if you do blocking stuff on the threads from that pool, eventually they’ll run out. One mistake people often make is to use runBlocking, so I thought I’d make sure. but you are saying launch fails immediately the first time after startup?
r

Ryan Rolnicki

05/19/2021, 12:46 PM
What are you doing inside that coroutine? If you are using a blocking function (think
while(true) sleep(100)
), it could exhibit this problem.