what is `DefaultDispatcher-worker-` ? and then th...
# getting-started
l
what is
DefaultDispatcher-worker-
? and then this suffix with
1
,
2
,
3
. does this goes after
3
too? I tried running code with Dispatchers.Default and .IO and I don't get to see
IODispatcher-worker-x
r
it's the name of the worker thread from the thread pool that the Default dispatcher uses. The number of threads in that pool is by default equal to the number of CPU cores, with a minimum of 2 (see the documentation of Dispatchers.Default). The reason that you don't see
IODispatcher-worker-x
is because technically, the IO dispatcher also uses the same threads as the Default dispatcher, to reduce thread switching in practice when switching between Default and IO dispatcher. This is an implementation detail, noted in the documentation of Dispatchers.IO:
This dispatcher and its views share threads with the Default dispatcher, so using
withContext(<http://Dispatchers.IO|Dispatchers.IO>) { ... }
when already running on the Default dispatcher typically does not lead to an actual switching to another thread. In such scenarios, the underlying implementation attempts to keep the execution on the same thread on a best-effort basis.
❤️ 1