43 |
|
* Full nonpublic constructor. |
44 |
|
*/ |
45 |
|
ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool, |
46 |
< |
boolean useSystemClassLoader) { |
47 |
< |
super(group, null, pool.nextWorkerThreadName(), 0L); |
46 |
> |
boolean useSystemClassLoader, boolean isInnocuous) { |
47 |
> |
super(group, null, pool.nextWorkerThreadName(), 0L, !isInnocuous); |
48 |
|
UncaughtExceptionHandler handler = (this.pool = pool).ueh; |
49 |
|
this.workQueue = new ForkJoinPool.WorkQueue(this, 0); |
50 |
|
super.setDaemon(true); |
56 |
|
|
57 |
|
/** |
58 |
|
* Creates a ForkJoinWorkerThread operating in the given thread group and |
59 |
< |
* pool. |
59 |
> |
* pool, and with the given policy for preserving ThreadLocals. |
60 |
|
* |
61 |
|
* @param group if non-null, the thread group for this thread |
62 |
|
* @param pool the pool this thread works in |
63 |
+ |
* @param preserveThreadLocals if true, always preserve the values of |
64 |
+ |
* ThreadLocal variables across tasks; otherwise they may be cleared. |
65 |
|
* @throws NullPointerException if pool is null |
66 |
+ |
* @since 19 |
67 |
|
*/ |
68 |
< |
ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool) { |
69 |
< |
this(group, pool, false); |
68 |
> |
protected ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool, |
69 |
> |
boolean preserveThreadLocals) { |
70 |
> |
this(group, pool, false, !preserveThreadLocals); |
71 |
|
} |
72 |
|
|
73 |
|
/** |
77 |
|
* @throws NullPointerException if pool is null |
78 |
|
*/ |
79 |
|
protected ForkJoinWorkerThread(ForkJoinPool pool) { |
80 |
< |
this(null, pool, false); |
80 |
> |
this(null, pool, false, false); |
81 |
|
} |
82 |
|
|
83 |
|
/** |
167 |
|
@SuppressWarnings("removal") |
168 |
|
private static final AccessControlContext innocuousACC; |
169 |
|
InnocuousForkJoinWorkerThread(ForkJoinPool pool) { |
170 |
< |
super(innocuousThreadGroup, pool, true); |
170 |
> |
super(innocuousThreadGroup, pool, true, true); |
171 |
|
} |
172 |
|
|
173 |
|
@Override @SuppressWarnings("removal") |
177 |
|
w.setInnocuous(); |
178 |
|
Thread t = Thread.currentThread(); |
179 |
|
ThreadLocalRandom.setInheritedAccessControlContext(t, innocuousACC); |
176 |
– |
ThreadLocalRandom.eraseThreadLocals(t); |
180 |
|
} |
181 |
|
|
182 |
|
@Override // to silently fail |