18 |
|
* the computation be restarted or cancelled. |
19 |
|
* |
20 |
|
* <p>Because <tt>FutureTask</tt> implements <tt>Runnable</tt>, a |
21 |
< |
* <tt>FutureTask</tt> can be submitted to an {@link Executor} for |
21 |
> |
* <tt>FutureTask</tt> can be submitted to an {@link Executor} for |
22 |
|
* current or deferred execution. |
23 |
|
* |
24 |
< |
* <p>A <tt>FutureTask</tt> can be used to wrap a <tt>Callable</tt> or |
25 |
< |
* <tt>Runnable</tt> object so that it can be scheduled for execution in a |
24 |
> |
* <p>A <tt>FutureTask</tt> can be used to wrap a <tt>Callable</tt> or |
25 |
> |
* <tt>Runnable</tt> object so that it can be scheduled for execution in a |
26 |
|
* thread or an <tt>Executor</tt>, cancel |
27 |
|
* computation before the computation completes, and wait for or |
28 |
|
* retrieve the results. If the computation threw an exception, the |
48 |
|
public FutureTask(Callable<V> callable) { |
49 |
|
// must set after super ctor call to use inner class |
50 |
|
super(); |
51 |
< |
setRunnable(new InnerCancellableFuture(callable)); |
51 |
> |
setRunnable(new InnerCancellableFuture<V>(callable)); |
52 |
|
} |
53 |
|
|
54 |
|
/** |
63 |
|
*/ |
64 |
|
public FutureTask(final Runnable runnable, final V result) { |
65 |
|
super(); |
66 |
< |
setRunnable(new InnerCancellableFuture |
66 |
> |
setRunnable(new InnerCancellableFuture<V> |
67 |
|
(new Callable<V>() { |
68 |
|
public V call() { |
69 |
|
runnable.run(); |
95 |
|
* @param timeout the maximum time to wait |
96 |
|
* @param unit the time unit of the timeout argument |
97 |
|
* @return value of this task |
98 |
< |
* @throws CancellationException if task producing this value was |
98 |
> |
* @throws CancellationException if task producing this value was |
99 |
|
* cancelled before completion |
100 |
|
* @throws ExecutionException if the underlying computation threw |
101 |
|
* an exception. |