This example aims to get number of processors available to currentĀ Java Virtual Machine (JVM).
Source Code
package com.beginner.examples;
public class GetProcessorsExample {
public static void main(String[] args){
Runtime run = Runtime.getRuntime();
// get available processors
int num = run.availableProcessors();
System.out.println(num + " processors are available to JVM.");
}
}
Output:
4 processors are available to JVM.