84 |
|
((Thread)r).interrupt(); |
85 |
|
else |
86 |
|
runnerUpdater.set(this, CANCELLED); |
87 |
+ |
|
88 |
+ |
done(); |
89 |
|
return true; |
90 |
|
} |
91 |
|
|
133 |
|
Object r = runner; |
134 |
|
if (r == DONE || r == CANCELLED) |
135 |
|
return; |
136 |
< |
if (runnerUpdater.compareAndSet(this, r, DONE)) |
136 |
> |
if (runnerUpdater.compareAndSet(this, r, DONE)) { |
137 |
> |
done(); |
138 |
|
return; |
139 |
+ |
} |
140 |
|
} |
141 |
|
} |
142 |
|
|
163 |
|
} |
164 |
|
|
165 |
|
/** |
166 |
+ |
* Protected method invoked when this task transitions to state |
167 |
+ |
* <tt>isDone</tt> (whether normally or via cancellation). The |
168 |
+ |
* default implementation does nothing. Subclasses may override |
169 |
+ |
* this method to invoke completion callbacks or perform |
170 |
+ |
* bookkeeping. Note that you can query status inside the |
171 |
+ |
* implementation of this method to determine whether this task |
172 |
+ |
* has been cancelled. |
173 |
+ |
*/ |
174 |
+ |
protected void done() { } |
175 |
+ |
|
176 |
+ |
/** |
177 |
|
* Reset the run state of this task to its initial state unless |
178 |
|
* it has been cancelled. (Note that a cancelled task cannot be |
179 |
|
* reset.) |