code: public void waitForTasks() throws IOException {
      // Wait for all submitted tasks to complete
      boolean wasInterrupted = false;
      IOException exception = null;
      for (NamedFuture future : this.futures) {
        try {
          if (wasInterrupted) {
            future.getFuture().cancel(true);
          } else {
            future.getFuture().get();
          }
        } catch (InterruptedException ie) {
          LOGGER.warn("Task was interrupted: " + future.getName());
          wasInterrupted = true;
          if (exception == null) {
            exception = new IOException(ie);
          }
        } catch (ExecutionException ee) {
          LOGGER.warn("Task failed: " + future.getName(), ee.getCause());
          if (exception == null) {
            exception = new IOException(ee.getCause());
          }
        }
      }
      if (wasInterrupted) {
        Thread.currentThread().interrupt();
      }
      if (exception != null && this.failPolicy == FailPolicy.FAIL_ONE_FAIL_ALL) {
        throw exception;
      }
  
      // clear so that more tasks can be submitted to this ParallelRunner
      futures.clear();
    }
docs: Wait for all submitted tasks to complete. The {@link ParallelRunner} can be reused after this call.
  @throws IOException