public int drainTo(Collection<? super E> c) {
    if (c == null)
      throw new NullPointerException();
    if (c == this)
      throw new IllegalArgumentException();
    lock.lock();
    try {
      for (E e : list) {
        c.add(e);
      }
      int n = list.size();
      list.clear();
      notFull.signalAll();
      return n;
    } finally {
      lock.unlock();
    }
  }
@throws UnsupportedOperationException {@inheritDoc}
@throws ClassCastException            {@inheritDoc}
@throws NullPointerException          {@inheritDoc}
@throws IllegalArgumentException      {@inheritDoc}
llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/PriorityBlockingDeque.java