Solved

Processor Identification

Posted on 2010-11-21
3
418 Views
Last Modified: 2012-05-10
Is there a way in Java to identify the processor that the current thread is assigned to?
0
Comment
Question by:jjcamachosanchez
  • 2
3 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 34184909
No, and it wouldn't make sense anyway. There is never a guarantee that the same processor/core will always execute the code for a particular thread. Therefore if there were such a call, the result would be useless as by the time it returns a result to your code, the code may be executing on a different processor/core!
0
 

Author Comment

by:jjcamachosanchez
ID: 34185245
I probably stated the question in the wrong way. What I want is to assess how many processors are executing threads of my program.
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 34185296
OK, but still it is something very JVM/OS/machine specific and so I doubt there is any way to do it in Java. I would say that your best bet would be to look at it from the other way, get you OS to tell you where/when threads of your java app are scheduled. Eg. a simple windows based approach is to check out Task Manager and look at the load on the processor cores. I am sure that are other methods available for other OS's and that are more sophisticated ways of doing it too.

Basically, it's the OS's scheduler that determines where threads run (java threads or others alike) and so that is where you need to hook to get that information, and since that would be OS specific, it is highly unlikely that Java would be able to get the info.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
map related example 6 55
SHA2 certs for IIS AND Java? 2 113
Java string replace 11 53
mysql jsp example issue 32 48
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

765 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