Answer the question
In order to leave comments, you need to log in
Dispatcher, Default and IO?
Text from the article:
You can see how Dispatchers.Default is initialized in the createDefaultDispatcher method. The default is DefaultScheduler. If you look at the implementation of Dispatchers.IO, it also uses the DefaultScheduler and allows you to create at least 64 threads on demand. Dispatchers.Default and Dispatchers.IO are implicitly related to each other because they use the same thread pool.
Here is the function
internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
if (useCoroutinesScheduler) DefaultScheduler else CommonPool
Answer the question
In order to leave comments, you need to log in
If I were you, I would stop reading this article and start reading the doc. These are strange conjectures, and immersion in absolutely superfluous details (you can immerse yourself in which, if you wish, yourself, there is a code, I don’t want to look).
Dispatchers.IO
The CoroutineDispatcher that is designed for offloading blocking IO tasks to a shared pool of threads.
Additional threads in this pool are created and are shutdown on demand. The number of threads used by tasks in this dispatcher is limited by the value of “kotlinx.coroutines.io.parallelism” (IO_PARALLELISM_PROPERTY_NAME) system property. It defaults to the limit of 64 threads or the number of cores (whichever is larger).
Moreover, the maximum configurable number of threads is capped by the kotlinx.coroutines.scheduler.max.pool.size system property. If you need a higher number of parallel threads, you should use a custom dispatcher backed by your own thread pool.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question