E - public class LinkedBlockingQueue<E>
extends java.util.AbstractQueue<E>
implements java.util.concurrent.BlockingQueue<E>, java.io.Serializable
| Constructor and Description |
|---|
LinkedBlockingQueue() |
LinkedBlockingQueue(java.util.Collection<? extends E> c) |
LinkedBlockingQueue(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
add(int index,
E o)
添加元素
|
void |
clear()
清空队列
|
int |
drainTo(java.util.Collection<? super E> c) |
int |
drainTo(java.util.Collection<? super E> c,
int maxElements) |
void |
fullyLock()
同时获取输入及输出锁
|
void |
fullyUnlock()
同时释放输入及输出锁
|
protected E |
get(int index)
为List接口提供的方法
|
protected int |
indexOf(E o) |
java.util.Iterator<E> |
iterator() |
java.util.List<E> |
list() |
boolean |
offer(E o)
添加元素,如果容量超出,则直接返回false
|
boolean |
offer(E o,
long timeout,
java.util.concurrent.TimeUnit unit)
添加元素,可设置操作的超时时间
|
E |
peek()
获取队列元素,不取出。
|
E |
poll()
获取队列元素,取出
|
E |
poll(long timeout,
java.util.concurrent.TimeUnit unit)
获取队列元素,取出
|
void |
put(E o)
向链表添加元素
|
int |
remainingCapacity()
获取链表的可用长度
|
protected E |
remove(int index)
删除元素
|
boolean |
remove(java.lang.Object o)
移除元素
|
protected E |
set(int index,
E element) |
int |
size()
获取链表长度
|
E |
take()
获取队列的元素
|
java.lang.Object[] |
toArray()
转换为数组
|
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
contains, containsAll, isEmpty, removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic LinkedBlockingQueue()
public LinkedBlockingQueue(int capacity)
public LinkedBlockingQueue(java.util.Collection<? extends E> c)
public void fullyLock()
public void fullyUnlock()
public int size()
public int remainingCapacity()
remainingCapacity in interface java.util.concurrent.BlockingQueue<E>public void put(E o) throws java.lang.InterruptedException
如果链表容量已满,会持续等待
put in interface java.util.concurrent.BlockingQueue<E>o - Ejava.lang.InterruptedExceptionpublic boolean offer(E o, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer in interface java.util.concurrent.BlockingQueue<E>o - 要添加的元素timeout - 超时时间unit - 时间单位java.lang.InterruptedExceptionpublic boolean offer(E o)
public E take() throws java.lang.InterruptedException
take in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic E poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll in interface java.util.concurrent.BlockingQueue<E>timeout - 操作超时时间unit - 时间单位java.lang.InterruptedExceptionpublic E poll()
poll in interface java.util.Queue<E>public E peek()
队列为空返回 null
peek in interface java.util.Queue<E>public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public java.lang.String toString()
toString in class java.util.AbstractCollection<E>public void clear()
public int drainTo(java.util.Collection<? super E> c)
drainTo in interface java.util.concurrent.BlockingQueue<E>public int drainTo(java.util.Collection<? super E> c, int maxElements)
drainTo in interface java.util.concurrent.BlockingQueue<E>public java.util.Iterator<E> iterator()
protected E get(int index)
index - 下标public boolean add(E e)
public boolean add(int index,
E o)
index - 下标o - Eprotected int indexOf(E o)
protected E remove(int index)
index - 下标public boolean remove(java.lang.Object o)
public java.util.List<E> list()