160 |
|
|
161 |
|
// any/all methods, each a little bit different than the other |
162 |
|
|
163 |
< |
public List<Future<?>> runAny(Collection<Runnable> tasks) |
163 |
> |
public List<Future<?>> runAny(List<Runnable> tasks) |
164 |
|
throws InterruptedException { |
165 |
|
if (tasks == null) |
166 |
|
throw new NullPointerException(); |
179 |
|
execute(f); |
180 |
|
} |
181 |
|
int first = waiter.await(); |
182 |
– |
if (first > 0) |
183 |
– |
Collections.swap(futures, first, 0); |
182 |
|
return futures; |
183 |
|
} finally { |
184 |
|
for (Future<?> f : futures) |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
< |
public List<Future<?>> runAny(Collection<Runnable> tasks, |
189 |
> |
public List<Future<?>> runAny(List<Runnable> tasks, |
190 |
|
long timeout, TimeUnit unit) |
191 |
|
throws InterruptedException { |
192 |
|
if (tasks == null || unit == null) |
207 |
|
execute(f); |
208 |
|
} |
209 |
|
int first = waiter.awaitNanos(nanos); |
212 |
– |
if (first > 0) |
213 |
– |
Collections.swap(futures, first, 0); |
210 |
|
return futures; |
211 |
|
} finally { |
212 |
|
for (Future<?> f : futures) |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
< |
public List<Future<?>> runAll(Collection<Runnable> tasks) |
219 |
> |
public List<Future<?>> runAll(List<Runnable> tasks) |
220 |
|
throws InterruptedException { |
221 |
|
if (tasks == null) |
222 |
|
throw new NullPointerException(); |
242 |
|
} |
243 |
|
} |
244 |
|
|
245 |
< |
public List<Future<?>> runAll(Collection<Runnable> tasks, |
245 |
> |
public List<Future<?>> runAll(List<Runnable> tasks, |
246 |
|
long timeout, TimeUnit unit) |
247 |
|
throws InterruptedException { |
248 |
|
if (tasks == null || unit == null) |
270 |
|
} |
271 |
|
} |
272 |
|
|
273 |
< |
public <T> List<Future<T>> callAny(Collection<Callable<T>> tasks) |
273 |
> |
public <T> List<Future<T>> callAny(List<Callable<T>> tasks) |
274 |
|
throws InterruptedException { |
275 |
|
if (tasks == null) |
276 |
|
throw new NullPointerException(); |
288 |
|
execute(f); |
289 |
|
} |
290 |
|
int first = waiter.await(); |
295 |
– |
if (first > 0) |
296 |
– |
Collections.swap(futures, first, 0); |
291 |
|
return futures; |
292 |
|
} finally { |
293 |
|
for (Future<T> f : futures) |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
< |
public <T> List<Future<T>> callAny(Collection<Callable<T>> tasks, |
298 |
> |
public <T> List<Future<T>> callAny(List<Callable<T>> tasks, |
299 |
|
long timeout, TimeUnit unit) |
300 |
|
throws InterruptedException { |
301 |
|
if (tasks == null || unit == null) |
315 |
|
execute(f); |
316 |
|
} |
317 |
|
int first = waiter.awaitNanos(nanos); |
324 |
– |
if (first > 0) |
325 |
– |
Collections.swap(futures, first, 0); |
318 |
|
return futures; |
319 |
|
} finally { |
320 |
|
for (Future<T> f : futures) |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
< |
public <T> List<Future<T>> callAll(Collection<Callable<T>> tasks) |
326 |
> |
public <T> List<Future<T>> callAll(List<Callable<T>> tasks) |
327 |
|
throws InterruptedException { |
328 |
|
if (tasks == null) |
329 |
|
throw new NullPointerException(); |
348 |
|
} |
349 |
|
} |
350 |
|
|
351 |
< |
public <T> List<Future<T>> callAll(Collection<Callable<T>> tasks, |
351 |
> |
public <T> List<Future<T>> callAll(List<Callable<T>> tasks, |
352 |
|
long timeout, TimeUnit unit) |
353 |
|
throws InterruptedException { |
354 |
|
if (tasks == null || unit == null) |