private void waitForWorkersToFinish() {
    final List<Future<?>> futures = myFutures;
    if (futures == null) return;
    myFutures = null;
    try {
      for (Future<?> future : futures) {
        future.get();
      }
      myTasks = null;
    }
    catch (ExecutionException | InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
private void waitForWorkersToFinish()