@Override
  public Object peek() throws InterruptedException {
    Object object = null;
    while (true) {

      if (takeWhenPeekInProgress) {
        try {
          take();
        } catch (CacheException ce) {
          throw new RuntimeException(ce) {};
        }
        takeWhenPeekInProgress = false;
      }
      object = super.peek();
      if (object == null) {
        synchronized (forWaiting) {
          object = super.peek();

          if (object == null) {
            boolean interrupted = Thread.interrupted();
            try {
              forWaiting.wait();
            } catch (InterruptedException e) {
              interrupted = true;
              /** ignore* */
              if (logger.isDebugEnabled()) {
                logger.debug("Interrupted exception while wait for peek", e);
              }
            } finally {
              if (interrupted) {
                Thread.currentThread().interrupt();
              }
            }
          } else {
            break;
          }
        }
      } else {
        break;
      }
    }
    return object;
  }
blocking peek. This method will not return till it has acquired a legitimate object from the
queue.
geode-junit/src/main/java/org/apache/geode/internal/cache/ha/TestBlockingHARegionQueue.java