在 JDK 的 java.lang.ref 包中的 Reference 有四种状态,分别是 Active,Pending,Enqueued,Inactive。它的一个好处根据源码就是:
* With this scheme the collector need only examine the next field in order
* to determine whether a Reference instance requires special treatment: If
* the next field is null then the instance is active; if it is non-null,
* then the collector should treat the instance normally.
那么,特殊对待是指什么,如果 next field 为空,那么具体会做什么处理,非空则会正常对待,那么所谓的正常对待是指什么。
我把比较完整的注释贴上来了,这里可以知道流程的转换过程。
但是具体的工作细节,这个估计只有熟悉具体GC回收机制的人才能解答了。
等待大神吧。