Skip to content
- FIFO (First In First Out) data structure.
- Basic operations
- Insert – Offer
- Remove – Poll
- Examine – Peek
- Variants
- Priority queue – Poll gives the element based on the priority.
- Blocking queue – Blocks the request for offer until the space available. Same with poll – blocks until queue has an element to return.
- Deque – Double Ended Queue. Supports insertion and removal from front and the rear ends. Hence supports both stack and queue.
- Transfer Queue – Variant of blocking queue in which producer blocks until the consumer give an acknowledgement on the receipt.
- Delay queue – Variant of blocking queue in which an inserted element can only be available for poll (removal) once the set delay is expired.
- Java JDK queue
- Primary interface for queue is java.util.Queue.
- Supports implementations for blocking queue, priority queue, transfer queue, Delay queue on arrays and linked list.
- Applications
- Serving n items sequentially need a queue.
- If the producer and consumer works at different speeds, then there needs a queue (messaging queues)