Solved

Processor Identification

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 91
Java Loop 6 62
web services creation SOAP vs REST 5 42
iterator/ListIterator approach 17 27
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

809 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