WeakReferenceT


WeakReference<T> java.lang.ref

Java 1.2

This class refers to an object in a way that does not prevent that referent object from being finalized and reclaimed by the garbage collector. When the garbage collector determines that there are no more hard (direct) references to the object, and that there are no SoftReference objects that refer to the object, it clears the WeakReference and marks the referent object for finalization . At some point after this, it also enqueues the WeakReference on its associated ReferenceQueue , if there is one, in order to provide notification that the referent has been reclaimed.

WeakReference is used by java.util.WeakHashMap to implement a hashtable that does not prevent the hashtable key object from being garbage-collected . WeakHashMap is useful when you want to associate auxiliary information with an object but do not want to prevent the object from being reclaimed.

Figure 10-90. java.lang.ref.WeakReference<T>

 public class  WeakReference<T>  extends Reference<T> {  // Public Constructors  public  WeakReference  (T  referent  );        public  WeakReference  (T  referent  , ReferenceQueue<? super T>  q  );   } 



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