Saturday 9 August 2014

Number of processors available to JVM

RunTime class provides availableProcessors() method, to get the number of processors available to JVM.

public class AvailableProcessors {
    public static void main(String args[]){
        Runtime r = Runtime.getRuntime();
        
        System.out.print("Available processors are ");
        System.out.println(r.availableProcessors());
    }
}

Sample Output
Available processors are 4



                                                             Home

No comments:

Post a Comment