ReferenceQueueT


ReferenceQueue<T> java.lang.ref

Java 1.2

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( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net