how many threads do scala's parallel collections use by default?

multithreading, parallel-processing, scala

Solution

Assuming there are no concurrently running processes and/or threads, meaning that all the CPU and cores are idle, this will be 1 thread per logical processor on the CPU. For example, if you have an Intel processor with 4 cores, but those cores have hyperthreading, then there will be 8 worker threads executing the parallel operation..

In any case, this is the same value returned by the `availableProcessors` method in the JDK.

Be aware that the `tabulate` call in your example is not parallel - it is executed sequentially.

Problem

When I call `Array.tabulate(100)(i=>i).par map { _+ 1}`, how many threads are being used? Thanks

Original source