CoroutineScope(<Dispatchers.IO>).launch{ print("Th...
# coroutines
v
CoroutineScope(Dispatchers.IO).launch{ print("This is before delay") delay(1000) print("This is after delay") } why does it not print after delay text
z
Where are you running this? If it’s just a main function, I think the IO dispatcher’s thread pool might use daemon threads?
👍 1
v
I am not using runBlocking just running in to the main function
g
Coroutines are like daemon threads and use daemon threads for standard dispatchers thread pools. Your program finished before delay is finished You can use runBlocking or suspend main()
👍 1
It also not the best way to run even top level coroutines, I would say that even GlobalSgope is better, it essentially the same, but doesn't require additional scope and more explicit
👍 1