Name: mr33420 Date: 11/17/98
I am trying to use SoftReference objects to
implement a cache which re-uses cached objects.
I would like to use the SoftReference object
to tell me when one of my cached objects is
no longer strongly referenced, since then it
is safe for me to re-use it (by creating a new
strong reference to the object and handing it
out to my client).
My idea was to create a SoftReference to my
object, register the SoftReference with a
ReferenceQueue, and then when the SoftReference
is queued, I could just pick up the referent and
re-use it.
However, according to the SoftReference API
doc, the SoftReference is unconditionally
cleared when it is enqueued on my ReferenceQueue,
meaning that at that point I have no way to get
a strong reference to my object any more.
I need a constructor for SoftReference which
registers it with my queue and configures it
so that it will NOT be automatically cleared
when queued.
(Review ID: 42837)
======================================================================