ThreadLocal should have a per-thread close method

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 8u45
    • Component/s: core-libs

      A DESCRIPTION OF THE REQUEST :
      Theeadlocal is a good idea but can lead to memory leaks when used in a thread pool as there is no defined mechanism for removing all of the current thread's objects.

      JUSTIFICATION :
      Avoid more leaks!

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      static ThreadLocal tl = new ThreatLocal;
      try {
       // long section that uses tl
      } finally {
        tl.close();
      }

      Developers should NOT have to resort to the brilliant but excessive kludgery shown here:http://www.javaspecialists.eu/archive/Issue229.html

      CUSTOMER SUBMITTED WORKAROUND :
      http://www.javaspecialists.eu/archive/Issue229.html

            Assignee:
            Paul Sandoz
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: