Available Processors Using Java Runtime
Chapter:
Run Time
Last Updated:
06-04-2016 19:58:16 UTC
Program:
/* ............... START ............... */
public class ProcessorJavaRunTimeExample {
public static void main(String args[]) {
Runtime runtime = Runtime.getRuntime();
int numberOfProcessors = runtime.availableProcessors();
System.out.println(numberOfProcessors + " processor available");
}
}
/* ............... END ............... */
Output
Notes:
-
Get current Java Runtime using getRuntime() method of Runtime class.
- Use availableProcessors method to determine how many processors are available to the Java Virtual Machine (JVM).
Tags
Available Processors, Java