< prev index next >

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

Print this page

        

*** 157,177 **** * 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(); 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(); } /** * Returns {@code true} if there is a value in the current thread's copy of * this thread-local variable, even if that values is {@code null}. --- 157,188 ---- * by an invocation of the {@link #initialValue} method. * * @return the current thread's value of this thread-local */ public T get() { ! return get(Thread.currentThread()); ! } ! ! /** ! * Returns the value in the current kernel thread's copy of this ! * thread-local variable. ! */ ! T getCarrierThreadLocal() { ! return get(Thread.currentCarrierThread()); ! } ! ! 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(t); } /** * Returns {@code true} if there is a value in the current thread's copy of * this thread-local variable, even if that values is {@code null}.
*** 189,201 **** * 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() { T value = initialValue(); - Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) { map.set(this, value); } else { createMap(t, value); --- 200,211 ---- * 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(Thread t) { T value = initialValue(); ThreadLocalMap map = getMap(t); if (map != null) { map.set(this, value); } else { createMap(t, value);
< prev index next >