Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Identify threads in Eclipse Debug Perspective?

Tags:

java

eclipse

I am developing a Java application which has some threads. I print in the console the threadId, for instance 17, 18, 19, and so on. But when I have the debug perspective open, I have this "Debug" window (most up-left window), which shows me the current threads, but they use [Thread-2], [thread-3]. The numbers not necessarly match the ThreadIds.

Is there any way so I can correlate the ThreadId I get in my console to the thread shown in the "Debug" window?

like image 532
JSBach Avatar asked Mar 22 '11 11:03

JSBach


2 Answers

I don't know of a way to do that.

However, there is another approach. Those thread names are generated automatically by the Thread constructor you are using. However, there is a method called Thread.setName() that allows you to change the thread's name. You could possibly tweak your application to change the names of the threads that it creates to match the thread's ids.

like image 117
Stephen C Avatar answered Sep 21 '22 01:09

Stephen C


There is nothing as such in Eclipse, but if you want to find which thread, then add debugging point on the code and call the

Thread.currentThread();

to find out the thread, which is currently executing.

Watch this thread for more information on the same.

http://dev.eclipse.org/mhonarc/lists/platform-debug-dev/msg00845.html

like image 34
Phani Avatar answered Sep 20 '22 01:09

Phani