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

ThreadLocal should have a per-thread close method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u45
    • 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

            psandoz Paul Sandoz
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: