Class FinalizablePhantomReference<T>
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.PhantomReference<T>
com.google.common.base.FinalizablePhantomReference<T>
- All Implemented Interfaces:
FinalizableReference
@GwtIncompatible
public abstract class FinalizablePhantomReference<T>
extends PhantomReference<T>
implements FinalizableReference
Phantom reference with a
finalizeReferent()
method which a background thread invokes
after the garbage collector reclaims the referent. This is a simpler alternative to using a
ReferenceQueue
.
Unlike a normal phantom reference, this reference will be cleared automatically.
- Since:
- 2.0
- Author:
- Bob Lee
-
Constructor Summary
ModifierConstructorDescriptionprotected
FinalizablePhantomReference
(@Nullable T referent, FinalizableReferenceQueue queue) Constructs a new finalizable phantom reference. -
Method Summary
Methods inherited from class java.lang.ref.PhantomReference
get
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, isEnqueued, reachabilityFence, refersTo
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.common.base.FinalizableReference
finalizeReferent
-
Constructor Details
-
FinalizablePhantomReference
Constructs a new finalizable phantom reference.- Parameters:
referent
- to phantom referencequeue
- that should finalize the referent
-