Home >Java >javaTutorial >What is the difference between ArrayBlockingQueue and LinkedBlockingQueue?
The blocking queue interface is part of the Java.util.concurrent package. Blocking queues are designed for producer-consumer queues and also support collections. The interface is divided into four parts of methods that support all types of operations on the queue. It does not accept empty keys. Both ArrayBlockingQueue and LinkedBlockingQueue implement the blocking queue interface
Both ArrayBlockingQueue and LinkedBlockingQueue store elements in FIFO order. In both queues, element insertion always occurs at the tail of the queue, and element deletion always occurs at the head of the queue.
Key | ArrayBlockingQueue | LinkedBlockingQueue | |
---|---|---|---|
Basic | It is supported by an array | It is supported by a linked list Support | |
Bounded | It is bounded array queue. So once created, the capacity cannot be changed | It is an unbounded queue | |
Throughput | Its throughput is lower than chain queue | Chain queue has higher throughput than array-based Queue | |
Lock | It uses a single lock Biconditional algorithm | It has putLock for inserting elements in the queue and takeLock for removing elements from the queue |
The above is the detailed content of What is the difference between ArrayBlockingQueue and LinkedBlockingQueue?. For more information, please follow other related articles on the PHP Chinese website!