< prev index next >

src/java.base/share/classes/java/lang/ThreadLocal.java

Print this page
rev 50306 : imported patch loom-fibers

@@ -155,32 +155,42 @@
      * by an invocation of the {@link #initialValue} method.
      *
      * @return the current thread's value of this thread-local
      */
     public T get() {
-        Thread t = Thread.currentThread();
+        return get(Thread.currentThread());
+    }
+
+    /**
+     * Returns the value in the current kernel thread's copy of this
+     * thread-local variable.
+     */
+    T getKernelThreadLocal() {
+        return get(Thread.currentKernelThread());
+    }
+
+    private T get(Thread t) {
         ThreadLocalMap map = getMap(t);
         if (map != null) {
             ThreadLocalMap.Entry e = map.getEntry(this);
             if (e != null) {
                 @SuppressWarnings("unchecked")
                 T result = (T)e.value;
                 return result;
             }
         }
-        return setInitialValue();
+        return setInitialValue(t);
     }
 
     /**
      * Variant of set() to establish initialValue. Used instead
      * of set() in case user has overridden the set() method.
      *
      * @return the initial value
      */
-    private T setInitialValue() {
+    private T setInitialValue(Thread t) {
         T value = initialValue();
-        Thread t = Thread.currentThread();
         ThreadLocalMap map = getMap(t);
         if (map != null)
             map.set(this, value);
         else
             createMap(t, value);
< prev index next >