Hi! I am a newbie to coroutines. Are there any rec...
# coroutines
m
Hi! I am a newbie to coroutines. Are there any recommendations as to when to use coroutines and threads?
e
t
@elizarov Just watched you KotlinConf 18 talk which is really awesome. But would you consider to release a course (Coursera or Udemy) to have more proper lessons on Coroutines? Thanks
e
It was announced during the keynote. We are doing a specialization with Coursera and it will have a section on coroutines.
👍 5
a
Are coroutines an effective replacement for anything that launches threads within an executor service? In other words,
ExecutorService
and
submit
can be replaced completely with a
CoroutineScope
(or global scope) and
launch
correct?
l
@Allan Wang Coroutines are about taking callback hells away. When you do multithreading, you often need callbacks. But with coroutines, you keep it sequential, and you also get easy cancellation/error support, with just try/catch/finally
a
I understand the callback hell part, but in terms of just general runnables or launching, would coroutines effectively replace threads as well? Even if there are no benefits, are there any downsides? If not, using coroutines would help in the future if I need to further split my jobs
l
Any code has to run on a thread. We have
CoroutineDispatcher
to specify which thread(s) to use.