BlockingQueue

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);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值