简体   繁体   中英

How to Identify threads in Eclipse Debug Perspective?

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?

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.

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

Instead of printing the Thread ID, you could print the thread name. Thread.currentThread().getName() . That is the name shown in the debugger.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM