code: public static <T> List<T> collectFutures(Collection<Future<T>> futures) throws ExecutionException, InterruptedException
      {
          ArrayList<T> collected = new ArrayList<T>(futures.size());
  
          for (Future<T> future : futures)
                  collected.add(future.get());
  
          return collected;
      }
docs: Collects all future values in a collection into a list, and returns said list. This method will block until all future objects are collected.
  @param <T> the type of future object
  @param futures the collection of future objects
  @return a list containing the object from the future.
  @throws ExecutionException
  @throws InterruptedException