1 package cz.cuni.amis.utils;
2
3 import java.util.Collection;
4 import java.util.concurrent.ExecutionException;
5 import java.util.concurrent.Future;
6
7
8
9
10
11 public class Concurrent {
12
13 public static void waitForAll(Future[] futures) throws InterruptedException, ExecutionException {
14 for (Future f : futures) {
15 f.get();
16 }
17 }
18
19 public static boolean allAreDone(Future[] futures) {
20 for (Future f : futures) {
21 if (!f.isDone()) {
22 return false;
23 }
24 }
25 return true;
26 }
27
28
29 public static boolean allAreDone(Collection<? extends Future> futures) {
30 for (Future f : futures) {
31 if (!f.isDone()) {
32 return false;
33 }
34 }
35 return true;
36 }
37 }