33 |
|
* representing that task. |
34 |
|
* |
35 |
|
* @param task the task to submit |
36 |
+ |
* @param result the result to return upon completion |
37 |
+ |
* If you do not need a particular result, consider using <tt>Boolean.TRUE</tt>. |
38 |
|
* @return a Future representing pending completion of the task, |
39 |
< |
* and whose <tt>get()</tt> method will return an arbitrary value |
39 |
> |
* and whose <tt>get()</tt> method will return the given value |
40 |
|
* upon completion |
41 |
|
* @throws RejectedExecutionException if task cannot be scheduled |
42 |
|
* for execution |
43 |
|
*/ |
44 |
< |
Future<?> submit(Runnable task); |
44 |
> |
<T> Future<T> submit(Runnable task, T result); |
45 |
|
|
46 |
|
/** |
47 |
|
* Submits a value-returning task for execution and returns a Future |
168 |
|
* Note that a <em>completed</em> task could have |
169 |
|
* terminated either normally or by throwing an exception. |
170 |
|
* @param tasks the collection of tasks |
171 |
+ |
* @param result value for each task to return upon completion. |
172 |
+ |
* If you do not need a particular result, consider using <tt>Boolean.TRUE</tt>. |
173 |
|
* @return A list of Futures representing the tasks, in the same |
174 |
|
* sequential order as the given task list. If the task list is |
175 |
|
* non-empty, at least one element of this list is known to have |
180 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
181 |
|
* for execution |
182 |
|
*/ |
183 |
< |
List<Future<?>> runAny(List<Runnable> tasks) |
183 |
> |
<T> List<Future<T>> invokeAny(List<Runnable> tasks, T result) |
184 |
|
throws InterruptedException; |
185 |
|
|
186 |
|
/** |
190 |
|
* Note that a <em>completed</em> task could have |
191 |
|
* terminated either normally or by throwing an exception. |
192 |
|
* @param tasks the collection of tasks |
193 |
+ |
* @param result value for each task to return upon completion. |
194 |
+ |
* If you do not need a particular result, consider using <tt>Boolean.TRUE</tt>. |
195 |
|
* @param timeout the maximum time to wait |
196 |
|
* @param unit the time unit of the timeout argument |
197 |
|
* @return A list of Futures representing the tasks, in the same |
205 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
206 |
|
* for execution |
207 |
|
*/ |
208 |
< |
List<Future<?>> runAny(List<Runnable> tasks, |
209 |
< |
long timeout, TimeUnit unit) |
208 |
> |
<T> List<Future<T>> invokeAny(List<Runnable> tasks, T result, |
209 |
> |
long timeout, TimeUnit unit) |
210 |
|
throws InterruptedException; |
211 |
|
|
212 |
|
|
216 |
|
* Note that a <em>completed</em> task could have |
217 |
|
* terminated either normally or by throwing an exception. |
218 |
|
* @param tasks the collection of tasks |
219 |
+ |
* @param result value for each task to return upon completion. |
220 |
+ |
* If you do not need a particular result, consider using <tt>Boolean.TRUE</tt>. |
221 |
|
* @return A list of Futures representing the tasks, in the same |
222 |
|
* sequential order as the given task list, each of which has |
223 |
|
* completed. |
227 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
228 |
|
* for execution |
229 |
|
*/ |
230 |
< |
List<Future<?>> runAll(List<Runnable> tasks) |
230 |
> |
<T> List<Future<T>> invokeAll(List<Runnable> tasks, T result) |
231 |
|
throws InterruptedException; |
232 |
|
|
233 |
|
/** |
238 |
|
* Note that a <em>completed</em> task could have |
239 |
|
* terminated either normally or by throwing an exception. |
240 |
|
* @param tasks the collection of tasks |
241 |
+ |
* @param result value for each task to return upon completion. |
242 |
+ |
* If you do not need a particular result, consider using <tt>Boolean.TRUE</tt>. |
243 |
|
* @param timeout the maximum time to wait |
244 |
|
* @return A list of Futures representing the tasks, in the same |
245 |
|
* sequential order as the given task list. If the operation did |
252 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
253 |
|
* for execution |
254 |
|
*/ |
255 |
< |
List<Future<?>> runAll(List<Runnable> tasks, |
256 |
< |
long timeout, TimeUnit unit) |
255 |
> |
<T> List<Future<T>> invokeAll(List<Runnable> tasks, T result, |
256 |
> |
long timeout, TimeUnit unit) |
257 |
|
throws InterruptedException; |
258 |
|
|
259 |
|
/** |
274 |
|
* for execution |
275 |
|
*/ |
276 |
|
|
277 |
< |
<T> List<Future<T>> callAny(List<Callable<T>> tasks) |
277 |
> |
<T> List<Future<T>> invokeAny(List<Callable<T>> tasks) |
278 |
|
throws InterruptedException; |
279 |
|
|
280 |
|
/** |
298 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
299 |
|
* for execution |
300 |
|
*/ |
301 |
< |
<T> List<Future<T>> callAny(List<Callable<T>> tasks, |
301 |
> |
<T> List<Future<T>> invokeAny(List<Callable<T>> tasks, |
302 |
|
long timeout, TimeUnit unit) |
303 |
|
throws InterruptedException; |
304 |
|
|
318 |
|
* for execution |
319 |
|
*/ |
320 |
|
|
321 |
< |
<T> List<Future<T>> callAll(List<Callable<T>> tasks) |
321 |
> |
<T> List<Future<T>> invokeAll(List<Callable<T>> tasks) |
322 |
|
throws InterruptedException; |
323 |
|
|
324 |
|
/** |
341 |
|
* @throws RejectedExecutionException if any task cannot be scheduled |
342 |
|
* for execution |
343 |
|
*/ |
344 |
< |
<T> List<Future<T>> callAll(List<Callable<T>> tasks, |
344 |
> |
<T> List<Future<T>> invokeAll(List<Callable<T>> tasks, |
345 |
|
long timeout, TimeUnit unit) |
346 |
|
throws InterruptedException; |
347 |
|
|