home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 2.1 KB | 63 lines |
- /*
- * @(#)GuardedReference.java 1.4 98/03/18
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- package java.lang.ref;
-
-
- /**
- * Guarded reference objects, for use in implementing caches.
- *
- * <p> A <em>guarded</em> reference is the strongest type of reference object.
- * If a guarded reference is registered and the garbage collector determines at
- * a certain point in time that its referent is no longer strongly reachable,
- * then at some later time the collector will enqueue the guarded reference.
- *
- * <p> Note that the referent of a guarded reference may be strongly reachable
- * at the time that the reference is removed from its queue. Another guarded
- * reference referring to the same object may already have been removed from
- * some queue (perhaps even the same queue) and the referent made strongly
- * reachable again. Thus guarded references should not be used to finalize or
- * reclaim resources, but only to provide hints as to when resources might
- * profitably be considered for finalization or reclamation.
- *
- * @author Mark Reinhold
- * @see java.lang.ref.Reference
- * @since JDK1.2
- */
-
- public class GuardedReference extends Reference {
-
- /**
- * Create a new guarded reference that refers to the given object. The
- * new reference is not registered with any queue.
- */
- public GuardedReference(Object referent) {
- super(referent);
- }
-
- /**
- * Create a new guarded reference that refers to the given object and
- * is registered with the given queue.
- *
- * @exception NullPointerException If the <code>queue</code> argument
- * is <code>null</code>
- *
- */
- public GuardedReference(Object referent, ReferenceQueue q) {
- super(referent, q);
- this.state = ACTIVE;
- }
-
- }
-