// return true if terminated boolean waitFor(int millis) throws Throwable { try { for (Job<Void> job : mySubmittedPasses.values()) { job.waitForCompletion(millis); } return true; } catch (TimeoutException ignored) { return false; } catch (InterruptedException e) { return true; } catch (ExecutionException e) { throw e.getCause(); } }
void cancelAll(boolean waitForTermination) { for (Job<Void> submittedPass : mySubmittedPasses.values()) { submittedPass.cancel(); } if (waitForTermination) { try { while (!waitFor(50)) { int i = 0; } } catch (ProcessCanceledException ignored) { } catch (Error | RuntimeException e) { throw e; } catch (Throwable throwable) { LOG.error(throwable); } } mySubmittedPasses.clear(); }