Solved

Processor Identification

Posted on 2010-11-21
3
392 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

759 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

20 Experts available now in Live!

Get 1:1 Help Now