private static void sleepImpl(long millis,Closure closure){
  long start=System.currentTimeMillis();
  long rest=millis;
  long current;
  while (rest > 0) {
    try {
      Thread.sleep(rest);
      rest=0;
    }
 catch (    InterruptedException e) {
      if (closure != null) {
        if (DefaultTypeTransformation.castToBoolean(closure.call(e))) {
          return;
        }
      }
      current=System.currentTimeMillis();
      rest=millis + start - current;
    }
  }
}

private static void sleepImpl ( long millis , Closure closure ) { long start = System . currentTimeMillis ( ) ; long rest = millis ; long current ; while ( rest > 0 ) { try { Thread . sleep ( rest ) ; rest = 0 ; } catch ( InterruptedException e ) { if ( closure != null ) { if ( DefaultTypeTransformation . castToBoolean ( closure . call ( e ) ) ) { return ; } } current = System . currentTimeMillis ( ) ; rest = millis + start - current ; } } }
this method is used by both sleep ( ) methods to implement sleeping for the given time even if interrupted
