< prev index next >

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

Print this page
rev 50306 : imported patch loom-fibers

*** 155,186 **** * 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(); } /** * 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); --- 155,196 ---- * 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 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(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(Thread t) { T value = initialValue(); ThreadLocalMap map = getMap(t); if (map != null) map.set(this, value); else createMap(t, value);
< prev index next >