Find out total number of available processors to JVM

You are here : Home / Core Java Tutorials

In this core java tutorial we will find out total number of available processors to java virtual machine in your system in java.



Example/program to Find out total Number Of Processors Available to  JVM (Java virtual machine) In your System in java >
/**
* Example/program to Find out total Number Of Processors Available to
* JVM (Java virtual machine) In your System
*/
public class FindNumberOfAvailableProcessorsInSystemExample{
   public static void main(String[] args) {
         
     /**
     * first we will get the java Runtime object using the
     * Runtime class's getRuntime() method in java.
     */
       Runtime runtime = Runtime.getRuntime();
     
     /**
     * Now,  Find out total Number Of Processors Available to
     * JVM (Java virtual machine) In System
     * We will use native method availableProcessors in java.
     */
    
     int numberOfProcessors = runtime.availableProcessors();
    
     System.out.println("total Number Of Processors Available to "
             + "JVM (Java virtual machine) In your System = "+numberOfProcessors);
   }
}
/* output
total Number Of Processors Available to JVM (Java virtual machine) In your System = 4
*/


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


RELATED LINKS>

how to use toString method in java

Labels: Core Java JVM
eEdit
Must read for you :