The most basic collection is referred to as a list. A list has an unlimited number of elements, and you can add, read, or remove an element from any position. A concurrent list allows various threads to add or remove elements from the list at a time without producing any data inconsistency. Similar to lists, we have deques. A deque is a data structure similar to a queue, but in a deque, you can add or remove elements from either the front (head) or back (tail).
In this recipe, you will learn how to use blocking deques in your concurrent programs. The main difference between blocking deques and non-blocking deques is that blocking deques have methods to insert and delete elements that, if not done immediately because the list is either full or empty, block the thread that make the call until the operation could be carried out. Java includes the LinkedBlockingDeque class that implements...