如何在Eclipse Debug Perspective中识别线程? [英] How to Identify threads in Eclipse Debug Perspective?

查看:29
本文介绍了如何在Eclipse Debug Perspective中识别线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有一些线程的Java应用程序.我在控制台中打印threadId,例如17、18、19,依此类推.但是,当我打开调试透视图时,我有这个调试"窗口(最左上角的窗口),向我显示了当前线程,但是它们使用[Thread-2],[thread-3].数字不一定与ThreadId匹配.

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.

有什么办法可以将我在控制台中获得的ThreadId与调试"窗口中显示的线程相关联吗?

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.

但是,还有另一种方法.这些线程名称由您使用的Thread构造函数自动生成.但是,有一种名为 Thread.setName()的方法,该方法允许您更改线程的名称.您可以调整应用程序以更改其创建的线程名称以匹配线程的ID.

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.

这篇关于如何在Eclipse Debug Perspective中识别线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆