When I call Array.tabulate(100)(i=>i).par map { _+ 1}
, how many threads are being used?
Thanks
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With