processors count

Posted on 2013-05-29
Last Modified: 2013-06-11
hi guys

I am trying to find out how many processors i have in my Production server. i am using this code

but does that give a correct count of the number of processors?

What if i have 2 boxes in a cluster and each box has one processor, will the
above code return me correct number of processors.

Question by:royjayd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 86

Expert Comment

ID: 39205225
What hardware/software would you have that would allow clustering of processors?
LVL 16

Expert Comment

ID: 39206844
No. I think you mean "nodes" when you write "boxes" in the cluster?! Am I right?
If this is the case then "Runtime.getRuntime().availableProcessors();" will be executed on each one of the boxes, because each box runs it's own JVM.
Btw Runtime.getRuntime().availableProcessors(); returns number of the cores of the processor, in your case if you have 1 processor with 4 cores, the returnd value will be "4".

Author Comment

ID: 39207627
well the problem is i asked my system admin how many CPUs we are using in Production environment and he says 4
but my java code  

returns 1

so i am not sure why there is a mismatch.
However one thing i am pretty sure is it is a production box and it cannot have just one cpu.
so as per my system admin 4 cpus sounds about right.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 86

Expert Comment

ID: 39208126
What OS are you using?

Author Comment

ID: 39208138
Linux OS on production box , no application servers.
Its just a single java program running in one single jvm.
LVL 86

Accepted Solution

CEHJ earned 325 total points
ID: 39208220
cat /proc/cpuinfo

Open in new window

Would be worth trying. Java uses


Open in new window

You might also need to look at ulimit and quota
LVL 86

Expert Comment

ID: 39239616

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding multiple JVM environments to RedHat 6 7 70
Java basic valueOf question 1 35
Fast way to search item into Java Array (Rhino compatible) 2 39
Java array 10 68
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question