public class LinkedBlockingQueue<E> extends AbstractQueue<E>
        implements BlockingQueue<E>, java.io.Serializable {
    private static final long serialVersionUID = -6903933977591709194L;
    /**
     * Linked list node class
     */
    static class Node<E> {//存储数据的节点
        E item;
 
        Node<E> next;
        Node(E x) { item = x; }
    }
    /** The capacity bound, or Integer.MAX_VALUE if none */
    private final int capacity;//链表的最大长度,如果不设置值默认为Integer.MAX_VALUE
    /** Current number of elements */
    private final AtomicInteger count = new AtomicInteger(0);//统计数量线程安全
    /**
     * Head of linked list.
     * Invariant: head.item == null
     */
    private transient Node<E> head;//头节点
    /**
     * Tail of linked list.
     * Invariant: last.next == null
     */
    private transient Node<E> last;//尾节点
    /** Lock held by take, poll, etc */
    private final ReentrantLock takeLock = new ReentrantLock();//tackLock
    /** Wait queue for waiting takes */
    private final Condition notEmpty = takeLock.newCondition();//tackLock条件不为空
    /** Lock held by put, offer, etc */
    private final ReentrantLock putLock = new ReentrantLock();//putLock
    /** Wait queue for waiting puts */
    private final Condition notFull = putLock.newCondition();//putLock条件没满
    public LinkedBlockingQueue() {
            this(Integer.MAX_VALUE);
    }
    public LinkedBlockingQueue(int capacity) {
    	if (capacity <= 0) throw new IllegalArgumentException();
    	this.capacity = capacity;
    	last = head = new Node<E>(null);//默认last=head=空节点
    }