public void awaitCompletion(long timeoutSecs) throws InterruptedException {
  long end=System.nanoTime() + timeoutSecs * 1000 * 1000000L;
  for (  Thread t : threads) {
    long time=System.nanoTime();
    if (time < end) {
      t.join(((end - time) / 1000000),(int)((end - time) % 1000000));
    }
  }
  check(numthreads,numthreads,0);
}

public void awaitCompletion ( long timeoutSecs ) throws InterruptedException { long end = System . nanoTime ( ) + timeoutSecs * 1000 * 1000000L ; for ( Thread t : threads ) { long time = System . nanoTime ( ) ; if ( time < end ) { t . join ( ( ( end - time ) / 1000000 ) , ( int ) ( ( end - time ) % 1000000 ) ) ; } } check ( numthreads , numthreads , 0 ) ; }
wait for threads to all finish
