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 ?

You May Also Like:

Which data type would you choose for storing currency values like Trading Price in Java?
How would you print a given currency value for Indian Locale (INR Currency)?
Which classes in java are immutable ?
How would you round a double value to certain decimal Precision and Scale ?
What is BlockingQueue? How can we implement Producer and Consumer problem using Blocking Queue?

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

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