Package org.infinispan.commons.util
Class ProcessorInfo
- java.lang.Object
-
- org.infinispan.commons.util.ProcessorInfo
-
public class ProcessorInfo extends Object
Provides general information about the processors on this host.- Author:
- Tristan Tarrant
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
availableProcessors()
Returns the number of processors available to this process.static void
main(String[] args)
-
-
-
Method Detail
-
availableProcessors
public static int availableProcessors()
Returns the number of processors available to this process. On most operating systems this method simply delegates toRuntime.availableProcessors()
. However, before Java 10, under Linux this strategy is insufficient, since the JVM does not take into consideration the process' CPU set affinity and the CGroups quota/period assignment. Therefore this method will analyze the Linux proc filesystem to make the determination. Since the CPU affinity of a process can be change at any time, this method does not cache the result. Calls should be limited accordingly.
The number of available processors can be overridden via the system property infinispan.activeprocessorcount, e.g. java -Dinfinispan.activeprocessorcount=4 .... Note that this value cannot exceed the actual number of available processors.
Since Java 10, this can also be achieved via the VM flag -XX:ActiveProcessorCount=xx.
Note that on Linux, both SMT units (Hyper-Threading) and CPU cores are counted as a processor.- Returns:
- the available processors on this system.
-
main
public static void main(String[] args)
-
-