public E take() throws InterruptedException {
    E x;
    // Take a write lock. If the delegate's queue is empty we need it to await(), which will
    // drop the lock, then reacquire it; or if the queue is not empty we will use an iterator
    // to mutate the head.
    lock.writeLock().lockInterruptibly();
    try {
      while (delegate.isEmpty()) {
        notEmpty.await(); // await drops the lock, then reacquires it
      }
      final Iterator<E> iter = delegate.iterator();
      x = iter.next();
      iter.remove();
      if (!delegate.isEmpty()) {
        notEmpty.signal();
      }
    } finally {
      lock.writeLock().unlock();
    }
    return x;
  }
Retrieves and removes the head of this queue, waiting if necessary until an element becomes
available.
@return the head of this queue
@throws InterruptedException if interrupted while waiting
hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorkQueue.java