长度: 从Idea Community代码库的分析中,发现ThreadDescriptorImpl.java
(ThreadDescriptorImpl)是提供在调试窗口中显示线程描述的类(请参阅上面呈现问题的图像)。ID被称为thread.uniqueID()
。这里的线程是ThreadReferenceProxyImpl
类型,它扩展了ObjectReferenceProxyImpl
,其中实现了uniqueID方法。这个方法反过来从ObjectReference
类型的对象返回一个uniqueID。通过粗略搜索,在Idea代码库中未找到满足条件的ObjectReference
定义。后来发现它隐藏在JDI接口的定义中。从Idea设置中找到的JDI实现jar中,发现ObjectReferenceImpl
提供了uniqueID
方法的最终实现。以下是代码片段 -
private long myID;
private static synchronized long nextID()
{
return nextID++;
}
ObjectReferenceImpl(VirtualMachine aVm, Oop oRef)
{
super(aVm);
this.saObject = oRef;
this.myID = nextID();
}
public long uniqueID()
{
return this.myID;
}