code: public synchronized boolean lock() throws KeeperException, InterruptedException {
          if (isClosed()) {
              return false;
          }
          ensurePathExists(dir);
  
          return (Boolean) retryOperation(zop);
      }
docs: Attempts to acquire the exclusive write lock returning whether or not it was
  acquired. Note that the exclusive lock may be acquired some time later after
  this method has been invoked due to the current lock owner going away.