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
  • 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.

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 96
web application structure 18 76
Why my table column Id is not passed to java object? 4 38
What's wrong with this code? 4 22
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now