Java Thread Future waitForTasks(List futures)

Here you can find the source of waitForTasks(List futures)

Description

wait For Tasks

License

Open Source License

Declaration

public static int waitForTasks(List<Future> futures) 

Method Source Code

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

import java.util.List;
import java.util.concurrent.*;

public class Main {
    public static int waitForTasks(List<Future> futures) {
        int total = 0;
        for (Future future : futures) {
            try {
                future.get();//from  w ww.  ja  v a2 s .  c  o  m
                total++;
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        }
        futures.clear();
        return total;
    }
}

Related

  1. waitFor(Future future)
  2. waitForAll(List> futures)
  3. waitForAll(List> res)
  4. waitForCompletion(Collection> futures)
  5. waitForCompletion(Future[] futures)