private synchronized void sleep ( long waitNanos ) throws InterruptedException { while ( waitNanos > 0 && isRunning ( ) ) { long start = System . nanoTime ( ) ; TimeUnit . NANOSECONDS . timedWait ( this , waitNanos ) ; waitNanos -= System . nanoTime ( ) - start ; } }
Wait for the specified amount of time or until this service is stopped whichever comes first .