LinkedBlockingQueue的构造过程

LinkedBlockingQueue的构造

LinkedBlockingQueue<String> linkedBlockingQueue = new LinkedBlockingQueue<String>(20);

构造函数

public LinkedBlockingQueue(int capacity) {
    if (capacity <= 0) throw new IllegalArgumentException();
    this.capacity = capacity;
    last = head = new Node<E>(null);
}

重要的成员变量

private final ReentrantLock takeLock = new ReentrantLock();

private final Condition notEmpty = takeLock.newCondition();

private final ReentrantLock putLock = new ReentrantLock();

private final Condition notFull = putLock.newCondition();

LinkedBlockingQueue的构造

在这里插入图片描述

发布了104 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/zjuwzp/article/details/103838559