有界阻塞队列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 特点

  • 先进先出
posted @ 2021-07-05 14:32  Innocent_Blog  阅读(137)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css