public class WeakReference<T> extends Reference<T>
obj is
is weakly-reachable, the following
happens:
ref of references is determined. ref contains the
following elements:
obj.
obj is
either strongly or softly reachable.
ref are atomically cleared.
ref become eligible for
finalization.
ref will be enqueued
with their corresponding reference queues, if any.
SoftReference and a WeakReference is
the point of time at which the decision is made to clear and enqueue the
reference:
SoftReference should be cleared and enqueued as late as
possible, that is, in case the VM is in danger of running out of
memory.
WeakReference may be cleared and enqueued as soon as is
known to be weakly-referenced.
pendingNext| Constructor and Description |
|---|
WeakReference(T r)
Constructs a new weak reference to the given referent.
|
WeakReference(T r,
ReferenceQueue<? super T> q)
Constructs a new weak reference to the given referent.
|
public WeakReference(T r)
r - the referent to trackpublic WeakReference(T r, ReferenceQueue<? super T> q)
r - the referent to trackq - the queue to register to the reference object with. A null value
results in a weak reference that is not associated with any
queue.