< prev index next >

src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java

Print this page
@@ -298,10 +298,16 @@
       * Erases ThreadLocals by nulling out Thread maps.
       */
      static final void eraseThreadLocals(Thread thread) {
          U.putReference(thread, THREADLOCALS, null);
          U.putReference(thread, INHERITABLETHREADLOCALS, null);
+         // Ideally we should also clear the Thread's ScopedCache, but it is
+         // in the VM-internal JavaThread structure. This method is called so
+         // early in the lifetime of a ForkJoinPool thread that we don't expect
+         // any ScopeLocals to have yet been bound by this thread, so the
+         // ScopedCache should be empty at this point.
+         // U.putReference(thread, INHERITABLESCOPELOCALBINDINGS, null);
      }
  
      static final void setInheritedAccessControlContext(Thread thread,
                                                         @SuppressWarnings("removal") AccessControlContext acc) {
          U.putReferenceRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc);
< prev index next >