Mal wieder ein schöner Beitrag vom JavaChampion Dr. Heinz M. Kabutz zum Thema Parallelität in der JavaVM in der Ausgabe 220.

Besonders erwähnenswert:

But that’s not all! One of our fellow Java Champions found a case where he had a 16-4-2 machine (thus with 16 sockets, each with four cores and 2 hyperthreads per core) return the value 16! Based on the results on my i7 MacBook Pro, I would have expected the value to be 16 * 4 * 2 = 128. Run Java 8 on this machine, and it will configure the common Fork/Join pool to have a parallelism of only 15. As Brian Goetz pointed out on the list, “The VM doesn’t really have an opinion about what a processor is; it just asks the OS for a number. Similarly, the OS usually doesn’t care either, it asks the hardware. The hardware responds with a number, usually the number of “hardware threads”. The OS believes the hardware. The VM believes the OS.

Fortunately there is a workaround. On startup, you can specify the common pool parallelism with the system property java.util.concurrent.ForkJoinPool.common.parallelism. Thus we could start this code with -Djava.util.concurrent.ForkJoinPool.common.parallelism=128 and it would show us that our parallelism is now 128…

Wenn ich doch nur auch so viele Kerne, Threads usw. hätte… :)