Solved

Processor Identification

Posted on 2010-11-21
3
431 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
[X]
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
  • 2
3 Comments
 
LVL 36

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 36

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

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 Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

690 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