コード例 #1
0
 // 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();
   }
 }
コード例 #2
0
  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();
  }