According to the source code , it uses a PhantomReference . According to the documentation:
Phantom , , , . Phantom , Java.
, phantom phantom, - .
, , phantom : get phantom null.
, phantom , . , phantom, , .
PhantomReference :
referent - , phantom
q - , , null,
q ReferenceQueue. PhantomReference ReferenceQueue, referent phantom . , PhantomReference poll() remove() ReferenceQueue.
:
T objectToWatch = ...;
ReferenceQueue<T> referenceQueue = new ReferenceQueue<T>();
new PhantomReference<T>(objectToWatch, referenceQueue);
Reference<? extends T> nextReference = referenceQueue.remove();
: PhantomReference sibling SoftReference WeakReference, . java.lang.ref.