7 |
|
package java.util.concurrent; |
8 |
|
|
9 |
|
/** |
10 |
< |
* A cancellable asynchronous computation. |
11 |
< |
* |
12 |
< |
* <p><tt>FutureTask</tt> provides methods to start and cancel the |
13 |
< |
* computation, query to see if the computation is complete, and |
10 |
> |
* A cancellable asynchronous computation. This class provides a base |
11 |
> |
* implementation of {@link Future}, with methods to start and cancel |
12 |
> |
* a computation, query to see if the computation is complete, and |
13 |
|
* retrieve the result of the computation. The result can only be |
14 |
|
* retrieved when the computation has completed; the <tt>get</tt> |
15 |
|
* method will block if the computation has not yet completed. Once |
16 |
< |
* the computation is completed, the result cannot be changed, nor can |
17 |
< |
* 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 |
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 |
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 |
29 |
< |
* exception is propagated to any thread that attempts to retrieve the |
30 |
< |
* result. |
16 |
> |
* the computation has completed, the computation cannot be restarted |
17 |
> |
* or cancelled. |
18 |
|
* |
19 |
< |
* @see Executor |
19 |
> |
* <p>A <tt>FutureTask</tt> can be used to wrap a {@link Callable} or |
20 |
> |
* {@link java.lang.Runnable} object. Because <tt>FutureTask</tt> |
21 |
> |
* implements <tt>Runnable</tt>, a <tt>FutureTask</tt> can be |
22 |
> |
* submitted to an {@link Executor} for execution. |
23 |
|
* |
24 |
|
* @since 1.5 |
35 |
– |
* @spec JSR-166 |
36 |
– |
* @revised $Date$ |
37 |
– |
* @editor $Author$ |
25 |
|
* @author Doug Lea |
26 |
|
*/ |
27 |
|
public class FutureTask<V> extends CancellableTask implements Future<V> { |