code: private static boolean safeSleep(long milliseconds) {
  
      boolean interrupted = false;
  
      long timeout = (System.currentTimeMillis() + milliseconds);
  
      while (System.currentTimeMillis() < timeout) {
        try {
          Thread.sleep(milliseconds);
        }
        catch (InterruptedException cause) {
          interrupted = true;
        }
        finally {
          milliseconds = Math.min(timeout - System.currentTimeMillis(), 0);
        }
      }
  
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
  
      return !Thread.currentThread().isInterrupted();
    }
docs: Safely sleeps for the given amount of milliseconds.
  
  If the {@link Thread#currentThread() current Thread} is {@link Thread#isInterrupted() interrupted} while
  {@link Thread#sleep(long, int) sleeping}, then the {@link Thread#currentThread() current Thread} will continue
  to {@link Thread#sleep(long, int) sleep} until the given number of milliseconds have expired and the interrupt bit
  will be set on return.
  
  @param milliseconds the number of milliseconds that the {@link Thread#currentThread() current Thread} will sleep.
  @return {@literal true} if the {@link Thread#currentThread() current Thread} was able to
  {@link Thread#sleep(long, int)} for the given number of milliseconds uninterrupted.
  @see java.lang.Thread#sleep(long, int)