Reputation: 827
Is there a Java thread pool object which automatically load balances threads across the available cores or is this done for you by the JVM?
Upvotes: 1
Views: 103
Reputation: 118734
Since (most) JVMs use native threads, the scheduling of the threads is the responsibility to the operating system. There may well still be "green thread" implementations of the JVM (or, at least options for them, especially on older JVMs), but since "green threads" are implemented by the JVM itself, they tend to not scale across cores. A primary goal of using native threads was multi-processor compatibility. The JVM doesn't, typically, run at a low enough level within the operating environment to have control over a resource like the CPUs of the machine.
I keep qualifying which JVM because while the vast majority of folks use the Oracle/OpenJDK JVM, there are other JVMs, older JVMs, JVMs on embedded hardware that do not behave as the Oracle/OpenJDK JVM does.
Upvotes: 4