public interface BlockingQueue<E> extends Queue<E> {
boolean add(E e);
boolean offer(E e);
// 如队列空间不足 进行无限期等待
void put(E e) throws InterruptedException;
// 如队列空间不足 进行超时时间等待
boolean offer(E e, long timeout, TimeUnit unit)
throws InterruptedException;
// 如队列无元素 进行无限期等待
E take() throws InterruptedException;
// 如队列无元素 进行指定超时时间等待
E poll(long timeout, TimeUnit unit)
throws InterruptedException;
// 返回当前的剩余空间
int remainingCapacity();
// 移出指定对象 O(n)
boolean remove(Object o);
// 判断是否存在指定对象 O(n)
public boolean contains(Object o);
/**
* Removes all available elements from this queue and adds them
* to the given collection. This operation may be more
* efficient than repeatedly polling this queue. A failure
* encountered while attempting to add elements to
* collection {@code c} may result in elements being in neither,
* either or both collections when the associated exception is
* thrown. Attempts to drain a queue to itself result in
* {@code IllegalArgumentException}. Further, the behavior of
* this operation is undefined if the specified collection is
* modified while the operation is in progress.
*/
int drainTo(Collection<? super E> c);
/**
* Removes at most the given number of available elements from
* this queue and adds them to the given collection. A failure
* encountered while attempting to add elements to
* collection {@code c} may result in elements being in neither,
* either or both collections when the associated exception is
* thrown. Attempts to drain a queue to itself result in
* {@code IllegalArgumentException}. Further, the behavior of
* this operation is undefined if the specified collection is
* modified while the operation is in progress.
*/
int drainTo(Collection<? super E> c, int maxElements);
}