static void delay(long millis) throws InterruptedException {
  long nanos=millis * (1000 * 1000);
  final long wakeupTime=System.nanoTime() + nanos;
  do {
    if (millis > 0L)     Thread.sleep(millis);
 else     Thread.yield();
    nanos=wakeupTime - System.nanoTime();
    millis=nanos / (1000 * 1000);
  }
 while (nanos >= 0L);
}

static void delay ( long millis ) throws InterruptedException { long nanos = millis * ( 1000 * 1000 ) ; final long wakeupTime = System . nanoTime ( ) + nanos ; do { if ( millis > 0L ) Thread . sleep ( millis ) ; else Thread . yield ( ) ; nanos = wakeupTime - System . nanoTime ( ) ; millis = nanos / ( 1000 * 1000 ) ; } while ( nanos >= 0L ) ; }
delays , via thread . sleep , for the given millisecond delay , but if the sleep is shorter than specified , may re - sleep or yield until time elapses . ensures that the given time , as measured by system . nanotime ( ) , has elapsed .
