public synchronized boolean lock() throws KeeperException, InterruptedException {
  if (isClosed()) {
    return false;
  }
  ensurePathExists(dir);
  return (Boolean)retryOperation(zop);
}

public synchronized boolean lock ( ) throws KeeperException , InterruptedException { if ( isClosed ( ) ) { return false ; } ensurePathExists ( dir ) ; return ( Boolean ) retryOperation ( zop ) ; }
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 .
