All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.commons.async.Syncs Maven / Gradle / Ivy

There is a newer version: 1.0.9
Show newest version
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) {
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy