public <E> List<E> invokeAll(List<Callable<E>> callables)
      throws InterruptedException, ExecutionException {
    List<Future<E>> futures =
        executorService.invokeAll(
            callables, MULTITHREADED_TEST_TIMEOUT.getSeconds(), TimeUnit.SECONDS);

    List<E> returnValues = new ArrayList<>();
    for (Future<E> future : futures) {
      Assert.assertTrue(future.isDone());
      returnValues.add(future.get());
    }

    return returnValues;
  }
Testing infrastructure for running code across multiple threads.
jib-core/src/test/java/com/google/cloud/tools/jib/MultithreadedExecutor.java