Name
ReferenceQueue<T>
Synopsis
This class represents a queue (or linked
list) of Reference objects that have been enqueued
because the garbage collector has determined that the referent
objects to which they refer are no longer adequately reachable. It
serves as a notification system for object-reachability changes. Use
poll( ) to return the first
Reference object on the queue; the method returns
null if the queue is empty. Use remove(
) to return the first element on the queue, or, if the
queue is empty, to wait for a Reference object to
be enqueued. You can create as many ReferenceQueue
objects as needed. Specify a ReferenceQueue for a
Reference object by passing it to the
SoftReference( ), WeakReference(
), or PhantomReference( ) constructor.
A ReferenceQueue is
required to use PhantomReference objects. It is
optional with SoftReference and
WeakReference objects; for these classes, the
get( ) method returns null if
the referent object is no longer adequately reachable.
public class ReferenceQueue<T> { // Public Constructors public ReferenceQueue( ); // Public Instance Methods public Reference<? extends T> poll( ); public Reference<? extends T> remove( ) throws InterruptedException; public Reference<? extends T> remove(long timeout) throws IllegalArgumentException, InterruptedException; }
Passed To
PhantomReference.PhantomReference( ),
SoftReference.SoftReference( ),
WeakReference.WeakReference( )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access