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.10 by dl, Fri Sep 26 11:37:10 2003 UTC vs.
Revision 1.11 by dl, Sat Oct 18 12:29:33 2003 UTC

# Line 23 | Line 23 | package java.util.concurrent;
23   *
24   * @since 1.5
25   * @author Doug Lea
26 + * @param <V> The result type returned by this Future
27   */
28   public class FutureTask<V> extends CancellableTask implements Future<V> {
29  
30 +    /**
31 +     * Callable created in FutureTask(runnable, result) constructor
32 +     */
33 +    private static class RunnableAsCallable<V> implements Callable<V> {
34 +        private final Runnable runnable;
35 +        private final V result;
36 +        RunnableAsCallable(Runnable runnable, V result) {
37 +            this.runnable = runnable;
38 +            this.result = result;
39 +        }
40 +        public V call() {
41 +            runnable.run();
42 +            return result;
43 +        }
44 +    }
45 +
46      /**
47       * Constructs a <tt>FutureTask</tt> that will upon running, execute the
48       * given <tt>Callable</tt>.
# Line 57 | Line 74 | public class FutureTask<V> extends Cance
74          if (runnable == null)
75              throw new NullPointerException();
76          setRunnable(new InnerCancellableFuture<V>
77 <                    (new Callable<V>() {
61 <                        public V call() {
62 <                            runnable.run();
63 <                            return result;
64 <                        }
65 <                    }));
77 >                    (new RunnableAsCallable<V>(runnable, result)));
78      }
79  
80      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines