Java Reference
In-Depth Information
public void clear()
Clears this reference object so it has no referent object.
public boolean enqueue()
Adds this reference object to the reference queue with which
it is registered, if any. Returns TRue if the reference object was
enqueued and false if there is no registered queue or this ref-
erence object was already enqueued.
public boolean isEnqueued()
Returns true if this reference object has been enqueued
(either by the programmer or the garbage collector), and
false otherwise.
We defer a discussion of reference queues until Section 17.5.3 on page
459 .
Subclasses of Reference provide ways to bind the referent object to the
reference objectthe existing subclasses do this with a constructor argu-
ment. Once an object has been wrapped in a reference object you can
retrieve the object via get (and thus have a normal strong reference to
it) or you can clear the reference, perhaps making the referent unreach-
able. There is no means to change the object referred to by the referen-
ce object and you cannot subclass Reference directly.
17.5.2. Strengths of Reference and Reachability
In decreasing order of strength, the kinds of reference objects available
to you are SoftReference<T> , WeakReference<T> , and PhantomReference<T> .
These correspond to the reachability stages an object can pass through:
 
Search WWH ::




Custom Search