Understanding the Reference Handler thread

前端 未结 3 886
野性不改
野性不改 2021-02-07 00:59

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 dum

3条回答
  •  没有蜡笔的小新
    2021-02-07 01:24

    1) The Finalizer Thread calls finalizer methods. The Reference Thread has a similar purpose.

    http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/ref/Reference.java.htm

    The OpenJDK source states its is a

    High-priority thread to enqueue pending References

    The GC creates a simple linked list of references which need to be processed and this thread quickly adds them to a proper queue. The reason this is done in two phases is that the GC does nothing but find the References, this thread calls code which handles those references e.g. Call Cleaners, and notifies ReferenceQueue listeners.

    2) A lock is acquired for a synchronized method before it is entered.

    3-5) covered by Joachim ;)

提交回复
热议问题