有界阻塞队列LinkedBlockingQueue
1. 创建
LinkedBlockingQueue 可以通过构造方法,创建一个指定容量的有界队列,如果不指定,默认长度是Integer.MAX_VALUE
/**
* Creates a {@code LinkedBlockingQueue} with the given (fixed) capacity.
*
* @param capacity the capacity of this queue
* @throws IllegalArgumentException if {@code capacity} is not greater
* than zero
*/
public LinkedBlockingQueue(int capacity) {
if (capacity <= 0) throw new IllegalArgumentException();
this.capacity = capacity;
last = head = new Node<E>(null);
}
2 LinkedBlockingQueue 特点
- 先进先出
喜欢出发、喜欢离开、喜欢不一样的事物。——May