public boolean leave() throws KeeperException, InterruptedException {
  zooKeeper.delete(rootPath + "/" + name,0);
  while (true) {
synchronized (mutex) {
      List<String> list=zooKeeper.getChildren(rootPath,true);
      if (list.size() > 0) {
        mutex.wait();
      }
 else {
        return true;
      }
    }
  }
}

public boolean leave ( ) throws KeeperException , InterruptedException { zooKeeper . delete ( rootPath + "/" + name , 0 ) ; while ( true ) { synchronized ( mutex ) { List < String > list = zooKeeper . getChildren ( rootPath , true ) ; if ( list . size ( ) > 0 ) { mutex . wait ( ) ; } else { return true ; } } } }
wait until all nodes leave barrier
