Here you can find the source of waitForTasks(List
public static int waitForTasks(List<Future> futures)
//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; } }