了解引用处理程序线程 [英] Understanding the Reference Handler thread

查看:120
本文介绍了了解引用处理程序线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将继续深入了解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:

  1. 引用处理程序线程应该做什么?
  2. 应该将线程转储视为自下而上的原因,为什么堆栈跟踪以锁定开始,而不是至少在线程运行之后才出现lock语句?
  3. 本机方法"是什么意思?
  4. 为什么使用未知源",在这种情况下,线程转储无法重新调用源代码?
  5. 最后等待和锁定的对象相同,为什么?

和往常一样,我恳请回答所有问题,以便我将其标记为已回答.

as usual, I kindly ask to answer all the questions, so that I can mark answered.

推荐答案

  1. 可疑它处理JVM的运行终结器.这是一个实现细节,因此未在JVM规范中指定.
  2. 这仅意味着java.lang.ref.Reference$Lock已被锁定在之前行中提到的方法(即ReferenceHandler.run()中.
  3. 本机方法"仅表示该方法是通过本机(即非Java)代码(例如JNI)实现的.
  4. 未知源仅表示.class文件不包含任何源代码位置信息(至少针对此特定点).当方法是综合方法时(在这里看起来不像),或者在没有调试信息的情况下编译类,都可能发生 .
  5. 当线程在某个对象上等待时,它必须在调用跟踪的某个位置锁定了该对象,因此您不能确实有一个waiting on而没有相应的locked.
  1. I suspect it handles running finalizers for the JVM. It's an implementation detail and as such not specified in the JVM spec.
  2. This only means that the java.lang.ref.Reference$Lock was locked in the method mentioned in the line preceding it (i.e in ReferenceHandler.run().
  3. "Native Method" simply means that the method is implemented in native (i.e. non-Java) code (think JNI).
  4. 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.
  5. 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 corresponding locked.

这篇关于了解引用处理程序线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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