Java Thread Future waitForCompletion(Future[] futures)

Here you can find the source of waitForCompletion(Future[] futures)

Description

Waits for all threads to complete computation.

License

Open Source License

Parameter

Parameter Description
futures a parameter

Declaration

public static void waitForCompletion(Future<?>[] futures) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.ExecutionException;

import java.util.concurrent.Future;

public class Main {
    /**//from ww  w.j a  v a2s.co  m
     * Waits for all threads to complete computation.
     * 
     * @param futures
     */
    public static void waitForCompletion(Future<?>[] futures) {
        int size = futures.length;
        try {
            for (int j = 0; j < size; j++) {
                futures[j].get();
            }
        } catch (ExecutionException ex) {
            ex.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. unwrap(Throwable throwable, Class throwableA)
  2. waitFor(Future future)
  3. waitForAll(List> futures)
  4. waitForAll(List> res)
  5. waitForCompletion(Collection> futures)
  6. waitForTasks(List futures)