LinkedBlockingDeque class implements the
BlockingDeque text for more information about the interface.
Deque comes from the term "Double Ended Queue". A
Deque is thus a queue where
you can insert and remove elements from both ends of the queue.
LinkedBlockingDeque is a
Deque which will block if a thread attempts to take
elements out of it while it is empty, regardless of what end the thread is attempting to take elements from.
Here is how to instantiate and use a
BlockingDeque<String> deque = new LinkedBlockingDeque<String>(); deque.addFirst("1"); deque.addLast("2"); String two = deque.takeLast(); String one = deque.takeFirst();