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.

Industry Leaders: 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

717 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