code: public synchronized boolean      waitOnBarrier(long maxWait, TimeUnit unit) throws Exception
      {
          long            startMs = System.currentTimeMillis();
          boolean         hasMaxWait = (unit != null);
          long            maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_VALUE;
  
          boolean         result;
          for(;;)
          {
              result = (client.checkExists().usingWatcher(watcher).forPath(barrierPath) == null);
              if ( result )
              {
                  break;
              }
  
              if ( hasMaxWait )
              {
                  long        elapsed = System.currentTimeMillis() - startMs;
                  long        thisWaitMs = maxWaitMs - elapsed;
                  if ( thisWaitMs <= 0 )
                  {
                      break;
                  }
                  wait(thisWaitMs);
              }
              else
              {
                  wait();
              }
          }
          return result;
      }
docs: Blocks until the barrier no longer exists or the timeout elapses
  
  @param maxWait max time to block
  @param unit time unit
  @return true if the wait was successful, false if the timeout elapsed first
  @throws Exception errors