code: public void lock() {
          boolean wasInterrupted = false;
          while (true) {
              try {
                  impl.lockInterruptibly();
                  if (wasInterrupted) {
                      Thread.currentThread().interrupt();
                  }
                  return;
              }
              catch (InterruptedException e) {
                  wasInterrupted = true;
              }
          }
      }
docs: Acquires the lock.
  
  <p>Acquires the lock if it is not held by another thread and returns
  immediately, setting the lock hold count to one.
  
  <p>If the current thread
  already holds the lock then the hold count is incremented by one and
  the method returns immediately.
  
  <p>If the lock is held by another thread then the
  current thread becomes disabled for thread scheduling
  purposes and lies dormant until the lock has been acquired,
  at which time the lock hold count is set to one.