equal
deleted
inserted
replaced
28 /** |
28 /** |
29 * A thread that has it's thread locals, and inheritable thread |
29 * A thread that has it's thread locals, and inheritable thread |
30 * locals erased on construction. |
30 * locals erased on construction. |
31 */ |
31 */ |
32 public class ManagedLocalsThread extends Thread { |
32 public class ManagedLocalsThread extends Thread { |
33 private static final Unsafe UNSAFE; |
33 private static final jdk.internal.misc.Unsafe UNSAFE; |
34 private static final long THREAD_LOCALS; |
34 private static final long THREAD_LOCALS; |
35 private static final long INHERITABLE_THREAD_LOCALS; |
35 private static final long INHERITABLE_THREAD_LOCALS; |
36 |
36 |
37 public ManagedLocalsThread() { |
37 public ManagedLocalsThread() { |
38 eraseThreadLocals(); |
38 eraseThreadLocals(); |
75 UNSAFE.putObject(this, THREAD_LOCALS, null); |
75 UNSAFE.putObject(this, THREAD_LOCALS, null); |
76 UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null); |
76 UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null); |
77 } |
77 } |
78 |
78 |
79 static { |
79 static { |
80 UNSAFE = Unsafe.getUnsafe(); |
80 UNSAFE = jdk.internal.misc.Unsafe.getUnsafe(); |
81 Class<?> t = Thread.class; |
81 Class<?> t = Thread.class; |
82 try { |
82 try { |
83 THREAD_LOCALS = UNSAFE.objectFieldOffset |
83 THREAD_LOCALS = UNSAFE.objectFieldOffset |
84 (t.getDeclaredField("threadLocals")); |
84 (t.getDeclaredField("threadLocals")); |
85 INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset |
85 INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset |