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.91 by jsr166, Sun Jun 19 16:00:03 2011 UTC vs.
Revision 1.92 by jsr166, Mon Jun 20 05:23:56 2011 UTC

# Line 229 | Line 229 | public class FutureTask<V> implements Ru
229              Callable<V> c = callable;
230              if (c != null && state == NEW) {
231                  V result;
232 +                boolean ran;
233                  try {
234                      result = c.call();
235 +                    ran = true;
236                  } catch (Throwable ex) {
237 +                    result = null;
238 +                    ran = false;
239                      setException(ex);
236                    return;
240                  }
241 <                set(result);
241 >                if (ran)
242 >                    set(result);
243              }
244          } finally {
245              runner = null;
# Line 259 | Line 263 | public class FutureTask<V> implements Ru
263              !UNSAFE.compareAndSwapObject(this, runnerOffset,
264                                           null, Thread.currentThread()))
265              return false;
266 +        boolean ran = false;
267 +        int s = state;
268          try {
269              Callable<V> c = callable;
270 <            if (c != null && state == NEW) {
270 >            if (c != null && s == NEW) {
271                  try {
272                      c.call(); // don't set result
273 <                    return state == NEW;
273 >                    ran = true;
274                  } catch (Throwable ex) {
275                      setException(ex);
276                  }
277              }
272            return false;
278          } finally {
279              runner = null;
280 <            int s = state;
280 >            s = state;
281              if (s >= INTERRUPTING)
282                  handlePossibleCancellationInterrupt(s);
283          }
284 +        return ran && s == NEW;
285      }
286  
287      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines