LinkedBlockingQueue(FIFO)
容量:默认取得是Integer.MAX_VALUE
内部使用两把锁,所以使用AtomicInteger来计数保证原子性,出队入队用的不同的锁,互相不阻塞
属性:
AtomicInteger count 用来计数
Node head 头节点,初始化的时候 last = head = new Node
Node last :尾节点,入队的时候 last = last.next = node
出队的时候从头节点出队,把当前head=head.next, 吧head.item返回
出队代码:
private E dequeue() {// assert takeLock.isHeldByCurrentThread();// assert head.item == null;Node<E> h = head;Node<E> first = h.next;h.next = h; // help GChead = first;E x = first.item;first.item = null;return x;}
入队代码:
private void enqueue(Node<E> node) {// assert putLock.isHeldByCurrentThread();// assert last.next == null;last = last.next = node;}

