了解引用处理程序线程 [英] Understanding the Reference Handler thread
问题描述
我将继续深入了解Java Thread.不幸的是,我的Java认证没有涵盖这一部分,因此学习的唯一方法是发布一系列愚蠢的问题.拥有这么多年的Java开发经验,我有时想知道我仍然需要学习多少知识:-)
I am continuing my path to deep understanding of Java Thread. Unfortunately my Java Certification didn't cover that part, so the only way of learning is to post a series of dumb questions. With so many years of Java Development, I am sometimes wondering how much I still have to learn :-)
我现在特别注意参考处理程序线程.
In particular my attention is now with the reference handler thread.
"Reference Handler" daemon prio=10 tid=0x02da3400 nid=0xb98 in Object.wait() [0x0302f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x1aac0320> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x1aac0320> (a java.lang.ref.Reference$Lock)
现在出现了一些问题,其中有些我知道答案了,但我没有发布它,因为我想听听其他人的意见:
Now some questions are following, for some of them I know the answer, but I am not posting it, because I would like to hear someone else opinions:
- 引用处理程序线程应该做什么?
- 应该将线程转储视为自下而上的原因,为什么堆栈跟踪以锁定开始,而不是至少在线程运行之后才出现lock语句?
- 本机方法"是什么意思?
- 为什么使用未知源",在这种情况下,线程转储无法重新调用源代码?
- 最后等待和锁定的对象相同,为什么?
和往常一样,我恳请回答所有问题,以便我将其标记为已回答.
as usual, I kindly ask to answer all the questions, so that I can mark answered.
推荐答案
- 我可疑它处理JVM的运行终结器.这是一个实现细节,因此未在JVM规范中指定.
- 这仅意味着
java.lang.ref.Reference$Lock
已被锁定在之前行中提到的方法(即ReferenceHandler.run()
中. - 本机方法"仅表示该方法是通过本机(即非Java)代码(例如JNI)实现的.
- 未知源仅表示
.class
文件不包含任何源代码位置信息(至少针对此特定点).当方法是综合方法时(在这里看起来不像),或者在没有调试信息的情况下编译类,都可能发生 . - 当线程在某个对象上等待时,它必须在调用跟踪的某个位置锁定了该对象,因此您不能确实有一个
waiting on
而没有相应的locked
.
- I suspect it handles running finalizers for the JVM. It's an implementation detail and as such not specified in the JVM spec.
- This only means that the
java.lang.ref.Reference$Lock
was locked in the method mentioned in the line preceding it (i.e inReferenceHandler.run()
. - "Native Method" simply means that the method is implemented in native (i.e. non-Java) code (think JNI).
- Unknown Source only means that the
.class
file doesn't contain any source code location information (at least for this specific point). This can happen either when the method is a synthetic one (doesn't look like it here), or the class was compiled without debug information. - When a thread waits on some object, then it must have locked that object at some point down the call trace, so you can't really have a
waiting on
without a correspondinglocked
.
这篇关于了解引用处理程序线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!