这是阻塞队列的接口
public interface BlockingQueue<E> extends Queue<E>
继承自Queue接口
boolean add(E e);
添加元素方法 长度超出了会抛异常
boolean offer(E e);
添加元素的另一种方法 添加失败就返回false 官方更建议用这个
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();
计算剩余容量的方法
boolean remove(Object o);
删除元素方法
public boolean contains(Object o);
判断元素是否存在的方法
int drainTo(Collection<? super E> c);
将本队列所有元素清空 并将所有元素放入参数Collection方法
将本队列中指定数目的元素清空 并放入参数Collection的方法
int drainTo(Collection<? super E> c, int maxElements);
BlockingQueue接口讲解完毕