Can some help what will be the difference in both ...
# coroutines
a
Can some help what will be the difference in both approach
Copy code
Dispatchers.IO.limitedParallelism(64)

OR

System.setProperty(IO_PARALLELISM_PROPERTY_NAME, 50.toString())
Is it just 1st one will limit for anyone using the dispatcher instance created and 2nd one will always set the limit of each time we create a dispatcher instance Can someone share more insights on this
r
With limitedParallelism, you can create a view of a dispatcher, that limits the number of coroutines running in parallel to the given number. So, e.g.
Dispatchers.IO.limitedParallelism(4)
returns a dispatcher that uses the IO dispatcher, but runs at most 4 coroutines at the same time. Of course the number of parallelism could never be higher than the number of threads in the original Dispatcher (e.g. a single-threaded dispatcher with a parallelism of 4 makes no sense). Note that calling this function does not change the original dispatcher (IO in this case). The IO_PARALLELISM_PROPERTY_NAME sets the system-wide maximum number of threads used by
<http://Dispatchers.IO|Dispatchers.IO>
, so that applies to the IO dispatcher itself. Note that this is a JVM property only, if I am not mistaken.
👍 1