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 / GuardedReference.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.1 KB  |  63 lines

  1. /*
  2.  * @(#)GuardedReference.java    1.4 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 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.  * Guarded reference objects, for use in implementing caches.
  20.  *
  21.  * <p> A <em>guarded</em> reference is the strongest type of reference object.
  22.  * If a guarded reference is registered and the garbage collector determines at
  23.  * a certain point in time that its referent is no longer strongly reachable,
  24.  * then at some later time the collector will enqueue the guarded reference.
  25.  *
  26.  * <p> Note that the referent of a guarded reference may be strongly reachable
  27.  * at the time that the reference is removed from its queue.  Another guarded
  28.  * reference referring to the same object may already have been removed from
  29.  * some queue (perhaps even the same queue) and the referent made strongly
  30.  * reachable again.  Thus guarded references should not be used to finalize or
  31.  * reclaim resources, but only to provide hints as to when resources might
  32.  * profitably be considered for finalization or reclamation.
  33.  *
  34.  * @author Mark Reinhold
  35.  * @see java.lang.ref.Reference
  36.  * @since JDK1.2
  37.  */
  38.  
  39. public class GuardedReference extends Reference {
  40.  
  41.     /**
  42.      * Create a new guarded reference that refers to the given object.  The
  43.      * new reference is not registered with any queue.
  44.      */
  45.     public GuardedReference(Object referent) {
  46.     super(referent);
  47.     }
  48.  
  49.     /**
  50.      * Create a new guarded reference that refers to the given object and
  51.      * is registered with the given queue.
  52.      *
  53.      * @exception  NullPointerException  If the <code>queue</code> argument
  54.      *                                   is <code>null</code>
  55.      *
  56.      */
  57.     public GuardedReference(Object referent, ReferenceQueue q) {
  58.     super(referent, q);
  59.     this.state = ACTIVE;
  60.     }
  61.  
  62. }
  63.