Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class Main {
    /**
     * Blocks and waits for all Futures in the given collection to complete.
     * 
     * @param futures the collection of Futures.
     */
    public static void waitForCompletion(Collection<Future<?>> futures) {
        for (Future<?> future : futures) {
            try {
                future.get();
            } catch (ExecutionException ex) {
                throw new RuntimeException("Exception during execution", ex);
            } catch (InterruptedException ex) {
                throw new RuntimeException("Thread interrupted", ex);
            }
        }
    }
}