Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4190589

(ref) java.lang.ref.SoftReference: Add non-clearing variant

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic



      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)
      ======================================================================

            mr Mark Reinhold
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: