31 |
|
final ForkJoinPool pool; // the pool this thread works in |
32 |
|
|
33 |
|
/** |
34 |
+ |
* An initial name for a newly constructed worker, used until |
35 |
+ |
* onStart can establish a useful name. This removes need to |
36 |
+ |
* establish a name from worker startup path. |
37 |
+ |
*/ |
38 |
+ |
static final String provisionalName = "aForkJoinWorkerThread"; |
39 |
+ |
|
40 |
+ |
/** |
41 |
|
* Creates a ForkJoinWorkerThread operating in the given pool. |
42 |
|
* |
43 |
|
* @param pool the pool this thread works in |
44 |
|
* @throws NullPointerException if pool is null |
45 |
|
*/ |
46 |
|
protected ForkJoinWorkerThread(ForkJoinPool pool) { |
47 |
< |
super(pool.nextWorkerName()); |
41 |
< |
setDaemon(true); |
47 |
> |
super(provisionalName); // bootstrap name |
48 |
|
Thread.UncaughtExceptionHandler ueh = pool.ueh; |
49 |
|
if (ueh != null) |
50 |
|
setUncaughtExceptionHandler(ueh); |
51 |
+ |
setDaemon(true); |
52 |
|
this.pool = pool; |
53 |
|
pool.registerWorker(this.workQueue = new ForkJoinPool.WorkQueue |
54 |
|
(pool, this, pool.localMode)); |
86 |
|
* processing tasks. |
87 |
|
*/ |
88 |
|
protected void onStart() { |
89 |
+ |
String pref; // replace bootstrap name |
90 |
+ |
if (provisionalName.equals(getName()) && |
91 |
+ |
(pref = pool.workerNamePrefix) != null) |
92 |
+ |
setName(pref.concat(Long.toString(getId()))); |
93 |
|
} |
94 |
|
|
95 |
|
/** |