ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/FutureTask.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/FutureTask.java (file contents):
Revision 1.49 by dl, Wed May 17 13:00:36 2006 UTC vs.
Revision 1.50 by dl, Sun May 28 13:46:16 2006 UTC

# Line 235 | Line 235 | public class FutureTask<V> implements Ru
235          void innerSet(V v) {
236              for (;;) {
237                  int s = getState();
238 <                if (ranOrCancelled(s))
238 >                if (s == RAN)
239                      return;
240 <                if (compareAndSetState(s, RAN))
241 <                    break;
242 <            }
243 <            result = v;
244 <            releaseShared(0);
245 <            done();
240 >                if (s == CANCELLED) {
241 >                    releaseShared(0);
242 >                    return;
243 >                }
244 >                if (compareAndSetState(s, RAN)) {
245 >                    result = v;
246 >                    releaseShared(0);
247 >                    done();
248 >                    return;
249 >                }
250 >            }
251          }
252  
253          void innerSetException(Throwable t) {
254              for (;;) {
255                  int s = getState();
256 <                if (ranOrCancelled(s))
256 >                if (s == RAN)
257                      return;
258 <                if (compareAndSetState(s, RAN))
259 <                    break;
258 >                if (s == CANCELLED) {
259 >                    releaseShared(0);
260 >                    return;
261 >                }
262 >                if (compareAndSetState(s, RAN)) {
263 >                    exception = t;
264 >                    result = null;
265 >                    releaseShared(0);
266 >                    done();
267 >                    return;
268 >                }
269              }
256            exception = t;
257            result = null;
258            releaseShared(0);
259            done();
270          }
271  
272          boolean innerCancel(boolean mayInterruptIfRunning) {
# Line 269 | Line 279 | public class FutureTask<V> implements Ru
279              }
280              if (mayInterruptIfRunning) {
281                  Thread r = runner;
282 <                if (r != null) {
283 <                    Thread.yield(); // Heuristic to avoid stall on next lines
274 <                    if (r == runner)
275 <                        r.interrupt();
276 <                }
282 >                if (r != null)
283 >                    r.interrupt();
284              }
285              releaseShared(0);
286              done();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines