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

4 processor available

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

Similar Programs Chapter Last Updated
System Time Milliseconds In Java Example Run Time 17-06-2016
File Separator Using System Class Run Time 17-06-2016
Java Virtual Machine (JVM) Termination Example Run Time 17-06-2016
JVM to Run Garbage Collector Example Run Time 17-06-2016
Total Memory Java Virtual Machine (JVM) Example Run Time 17-06-2016
Java RunTime Example Run Time 17-06-2016
Maximum Memory Available to Java Virtual Machine(JVM) Run Time 09-07-2016
Free Memory In Java Example Run Time 09-07-2016

1