Here you can find the source of waitForCompletion(Collection
Parameter | Description |
---|---|
futures | the collection of Futures. |
public static void waitForCompletion(Collection<Future<?>> futures)
//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); } } } }