Java Thread Future waitForCompletion(Collection> futures)

Here you can find the source of waitForCompletion(Collection> futures)

Description

Blocks and waits for all Futures in the given collection to complete.

License

Open Source License

Parameter

Parameter Description
futures the collection of Futures.

Declaration

public static void waitForCompletion(Collection<Future<?>> futures) 

Method Source Code

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

public class Main {
    /**//from   www .  j  a  v a  2  s. c  o  m
     * 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);
            }
        }
    }
}

Related

  1. transferResult(final CompletionStage source, final CompletableFuture target)
  2. unwrap(Throwable throwable, Class throwableA)
  3. waitFor(Future future)
  4. waitForAll(List> futures)
  5. waitForAll(List> res)
  6. waitForCompletion(Future[] futures)
  7. waitForTasks(List futures)