103 |
|
if (callable == null) |
104 |
|
throw new NullPointerException(); |
105 |
|
this.callable = callable; |
106 |
< |
this.state = NEW; |
106 |
> |
this.state = NEW; // ensure visibility of callable |
107 |
|
} |
108 |
|
|
109 |
|
/** |
120 |
|
*/ |
121 |
|
public FutureTask(Runnable runnable, V result) { |
122 |
|
this.callable = Executors.callable(runnable, result); |
123 |
< |
this.state = NEW; |
123 |
> |
this.state = NEW; // ensure visibility of callable |
124 |
|
} |
125 |
|
|
126 |
|
public boolean isCancelled() { |
232 |
|
} |
233 |
|
if (ran) |
234 |
|
set(result); |
235 |
– |
callable = null; // null out upon use to reduce footprint |
235 |
|
} |
236 |
|
runner = null; |
237 |
|
if (state >= INTERRUPTING) { |
275 |
|
Thread.interrupted(); // clear interrupt from cancel(true) |
276 |
|
} |
277 |
|
} |
279 |
– |
if (!rerun) |
280 |
– |
callable = null; |
278 |
|
} |
279 |
|
return rerun; |
280 |
|
} |
291 |
|
} |
292 |
|
|
293 |
|
/** |
294 |
< |
* Removes and signals all waiting threads, and invokes done(). |
294 |
> |
* Removes and signals all waiting threads, invokes done(), and |
295 |
> |
* nulls out callable. |
296 |
|
*/ |
297 |
|
private void finishCompletion() { |
298 |
|
for (WaitNode q; (q = waiters) != null;) { |
312 |
|
break; |
313 |
|
} |
314 |
|
} |
315 |
+ |
|
316 |
|
done(); |
317 |
+ |
|
318 |
+ |
callable = null; // to reduce footprint |
319 |
|
} |
320 |
|
|
321 |
|
/** |