Class ProcessorInfo


  • public class ProcessorInfo
    extends java.lang.Object
    Provides general information about the processors on this host.
    Author:
    Jason T. Greene
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • availableProcessors

        public static int availableProcessors()
        Returns the number of processors available to this process. On most operating systems this method simply delegates to Runtime.availableProcessors(). However, on Linux, this strategy is insufficient, since the JVM does not take into consideration the process' CPU set affinity which is employed by cgroups and numactl. 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.
        Note tha on Linux, both SMT units (Hyper-Threading) and CPU cores are counted as a processor.
        Returns:
        the available processors on this system.