using launch(Dispatcher.Default) {..} on a single ...
# coroutines
g
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
where did you find a single core machine?
😁 3
g
cheapest machines of major cloud service providers have a single core
t
are you sure it’s the launch? you’re not using
runBlocking
somewhere for example?
g
I use runBlocking to start a new coroutine from a non-suspend function (main program entry function)
Copy code
runBlocking {
        launch(Dispatchers.Default) {
...
Is there a better way?
by the way, using Dispatchers.Unconfined works fine
t
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
What are you doing inside that coroutine? If you are using a blocking function (think
while(true) sleep(100)
), it could exhibit this problem.