- All Implemented Interfaces:
final class TimedSoftReference<T>
- extends java.lang.ref.SoftReference<T>
- implements java.lang.Runnable
A soft reference which is held strongly for a while after last access.
- Created. Referent held strongly. A task is scheduled into the request
processor for some time in the future (currently 30 seconds).
- Expired. After the timeout, the reference switches to a normal soft
- Touched. If the value is accessed before it is garbage collected,
whether the reference is expired or not, the reference is "touched".
This means that the referent is again held strongly and the timeout
is started from scratch.
- Dead. If after expiry there is no access before the next full GC cycle,
the GC algorithm may reclaim the reference. In this case the reference
of course dies. As a bonus, it will try to remove itself as the value
from a map of your choice, to make it convenient to use these references
as values in a caching map without leaking memory for the key.
- Jesse Glick
Create a soft reference with timeout.
|Methods inherited from class java.lang.ref.Reference
clear, enqueue, isEnqueued
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public TimedSoftReference(T o,
- Create a soft reference with timeout.
The supplied map serves double duty as a synchronization lock
for the reference's state changes.
o - the referent
m - a map in which this reference may serve as a value
k - the key whose value in
m may be this reference
public void run()
- Specified by:
run in interface
public T get()
get in class