96 |
|
/** |
97 |
|
* the main mechanics of invokeAny. |
98 |
|
*/ |
99 |
< |
private <T> T doInvokeAny(Collection<Callable<T>> tasks, |
99 |
> |
private <T> T doInvokeAny(Collection<? extends Callable<T>> tasks, |
100 |
|
boolean timed, long nanos) |
101 |
|
throws InterruptedException, ExecutionException, TimeoutException { |
102 |
|
if (tasks == null) |
119 |
|
// result, we can throw the last exception we got. |
120 |
|
ExecutionException ee = null; |
121 |
|
long lastTime = (timed)? System.nanoTime() : 0; |
122 |
< |
Iterator<Callable<T>> it = tasks.iterator(); |
122 |
> |
Iterator<? extends Callable<T>> it = tasks.iterator(); |
123 |
|
|
124 |
|
// Start one task for sure; the rest incrementally |
125 |
|
futures.add(ecs.submit(it.next())); |
171 |
|
} |
172 |
|
} |
173 |
|
|
174 |
< |
public <T> T invokeAny(Collection<Callable<T>> tasks) |
174 |
> |
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) |
175 |
|
throws InterruptedException, ExecutionException { |
176 |
|
try { |
177 |
|
return doInvokeAny(tasks, false, 0); |
181 |
|
} |
182 |
|
} |
183 |
|
|
184 |
< |
public <T> T invokeAny(Collection<Callable<T>> tasks, |
184 |
> |
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, |
185 |
|
long timeout, TimeUnit unit) |
186 |
|
throws InterruptedException, ExecutionException, TimeoutException { |
187 |
|
return doInvokeAny(tasks, true, unit.toNanos(timeout)); |
188 |
|
} |
189 |
|
|
190 |
< |
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks) |
190 |
> |
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) |
191 |
|
throws InterruptedException { |
192 |
|
if (tasks == null) |
193 |
|
throw new NullPointerException(); |
217 |
|
} |
218 |
|
} |
219 |
|
|
220 |
< |
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, |
220 |
> |
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, |
221 |
|
long timeout, TimeUnit unit) |
222 |
|
throws InterruptedException { |
223 |
|
if (tasks == null || unit == null) |