net.dongliu.commons.async.Syncs Maven / Gradle / Ivy
package net.dongliu.commons.async;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/**
* @author Dong Liu
*/
public class Syncs {
/**
* wait all futures finished
*/
public static void sync(Future... futures) {
for (Future future : futures) {
try {
future.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
} catch (ExecutionException e) {
}
}
}
/**
* wait all futures finished
*/
public static void sync(Collection futures) {
for (Future future : futures) {
try {
future.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
} catch (ExecutionException e) {
}
}
}
}