了解引用处理程序线程

编程入门 行业动态 更新时间:2024-10-28 10:36:24
本文介绍了了解引用处理程序线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将继续深入了解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 in ReferenceHandler.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 corresponding locked.
  • 更多推荐

    了解引用处理程序线程

    本文发布于:2023-11-26 05:34:34,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1632842.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:线程   程序

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!