src/java.base/share/classes/sun/misc/ManagedLocalsThread.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke

*** 28,38 **** /** * A thread that has it's thread locals, and inheritable thread * locals erased on construction. */ public class ManagedLocalsThread extends Thread { ! private static final Unsafe UNSAFE; private static final long THREAD_LOCALS; private static final long INHERITABLE_THREAD_LOCALS; public ManagedLocalsThread() { eraseThreadLocals(); --- 28,38 ---- /** * A thread that has it's thread locals, and inheritable thread * locals erased on construction. */ public class ManagedLocalsThread extends Thread { ! private static final jdk.internal.misc.Unsafe UNSAFE; private static final long THREAD_LOCALS; private static final long INHERITABLE_THREAD_LOCALS; public ManagedLocalsThread() { eraseThreadLocals();
*** 75,85 **** UNSAFE.putObject(this, THREAD_LOCALS, null); UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null); } static { ! UNSAFE = Unsafe.getUnsafe(); Class<?> t = Thread.class; try { THREAD_LOCALS = UNSAFE.objectFieldOffset (t.getDeclaredField("threadLocals")); INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset --- 75,85 ---- UNSAFE.putObject(this, THREAD_LOCALS, null); UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null); } static { ! UNSAFE = jdk.internal.misc.Unsafe.getUnsafe(); Class<?> t = Thread.class; try { THREAD_LOCALS = UNSAFE.objectFieldOffset (t.getDeclaredField("threadLocals")); INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset