void joinPool(ExecutorService pool){
  try {
    pool.shutdown();
    if (!pool.awaitTermination(2 * LONG_DELAY_MS,MILLISECONDS)) {
      try {
        threadFail("ExecutorService " + pool + " did not terminate in a timely manner");
      }
  finally {
        pool.shutdownNow();
        pool.awaitTermination(MEDIUM_DELAY_MS,MILLISECONDS);
      }
    }
  }
 catch (  SecurityException ok) {
  }
catch (  InterruptedException fail) {
    threadFail("Unexpected InterruptedException");
  }
}

void joinPool ( ExecutorService pool ) { try { pool . shutdown ( ) ; if ( ! pool . awaitTermination ( 2 * LONG_DELAY_MS , MILLISECONDS ) ) { try { threadFail ( "ExecutorService " + pool + " did not terminate in a timely manner" ) ; } finally { pool . shutdownNow ( ) ; pool . awaitTermination ( MEDIUM_DELAY_MS , MILLISECONDS ) ; } } } catch ( SecurityException ok ) { } catch ( InterruptedException fail ) { threadFail ( "Unexpected InterruptedException" ) ; } }
waits out termination of a thread pool or fails doing so .
