How to get number of available processors in Java ?

By | February 6, 2020

Hello Friends,
In this post we will talk and learn about How to get number of available processors in Java ?

  • To get the number of available processors we can use the availableProcessors() method from java.lang.Runtime Class.
  • This method usually returns the number of processors which are available to the Java virtual machine.
  • Once thing you should note that this number may vary during a particular call of the virtual machine.

Below is the source code for same:

Output of above program: 

Total available processors are: 12

NOTE:You should note that output of above program may Vary machine to machine

That’s all about How to get number of available processors in Java ?
If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *