home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / lang / ref / WeakReference.java < prev   
Encoding:
Java Source  |  1998-03-20  |  1.9 KB  |  60 lines

  1. /*
  2.  * @(#)WeakReference.java    1.3 98/03/18
  3.  *
  4.  * Copyright 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang.ref;
  16.  
  17.  
  18. /**
  19.  * Weak reference objects, for use in implementing simple caches and
  20.  * canonicalizing mappings.
  21.  *
  22.  * <p> A <em>weak</em> reference is a reference object that does not prevent
  23.  * its referent from being made finalizable, finalized, and then reclaimed.  If
  24.  * the garbage collector determines at a certain point in time that an object
  25.  * is no longer strongly reachable and has no guarded references, then at that
  26.  * time it will clear all weak references to the object and declare the object
  27.  * to be finalizable.  If a weak reference is registered at the moment the
  28.  * garbage collector clears it, then at some later time it will be enqueued.
  29.  *
  30.  * @author Mark Reinhold
  31.  * @see java.lang.ref.Reference
  32.  * @since JDK1.2
  33.  */
  34.  
  35. public class WeakReference extends Reference {
  36.  
  37.     /**
  38.      * Create a new weak reference that refers to the given object.  The new
  39.      * reference is not registered with any queue.
  40.      */
  41.     public WeakReference(Object referent) {
  42.     super(referent);
  43.     this.state = ACTIVE;
  44.     }
  45.  
  46.     /**
  47.      * Create a new weak reference that refers to the given object and is
  48.      * registered with the given queue.
  49.      *
  50.      * @exception  NullPointerException  If the <code>queue</code> argument
  51.      *                                   is <code>null</code>
  52.      *
  53.      */
  54.     public WeakReference(Object referent, ReferenceQueue q) {
  55.     super(referent, q);
  56.     this.state = ACTIVE;
  57.     }
  58.  
  59. }
  60.