14 |
|
|
15 |
|
/** |
16 |
|
* Factory and utility methods for {@link Executor}, {@link |
17 |
< |
* ExecutorService}, {@link ThreadFactory}, {@link Future}, and {@link |
18 |
< |
* Cancellable} classes defined in this package. |
17 |
> |
* ExecutorService}, {@link ThreadFactory}, and {@link Future} |
18 |
> |
* classes defined in this package. |
19 |
|
* |
20 |
|
* @since 1.5 |
21 |
|
* @author Doug Lea |
150 |
|
} |
151 |
|
|
152 |
|
/** |
153 |
< |
* Executes a Runnable task and returns a Cancellable representing that |
153 |
> |
* Executes a Runnable task and returns a Future representing that |
154 |
|
* task. |
155 |
|
* |
156 |
|
* @param executor the Executor to which the task will be submitted |
157 |
|
* @param task the task to submit |
158 |
< |
* @return a Cancellable representing pending completion of the task |
158 |
> |
* @return a Future representing pending completion of the task, |
159 |
> |
* and whose <tt>get()</tt> method will return <tt>Boolean.TRUE</tt> |
160 |
> |
* upon completion |
161 |
|
* @throws RejectedExecutionException if task cannot be scheduled |
162 |
|
* for execution |
163 |
|
*/ |
164 |
< |
public static Cancellable execute(Executor executor, Runnable task) { |
164 |
> |
public static Future<Boolean> execute(Executor executor, Runnable task) { |
165 |
|
FutureTask<Boolean> ftask = new FutureTask<Boolean>(task, Boolean.TRUE); |
166 |
|
executor.execute(ftask); |
167 |
|
return ftask; |