The most basic collection is the list. A list has an undetermined number of elements and you can add, read, or remove the element of any position. Concurrent lists allow the various threads to add or remove elements in the list at a time without producing any data inconsistency.
In this recipe, you will learn how to use non-blocking lists in your concurrent programs. Non-blocking lists provide operations that, if the operation can't be done immediately (for example, you want to get an element of the list and the list is empty), they throw an exception or return a
null value, depending on the operation. Java 7 has introduced the
ConcurrentLinkedDeque class that implements a non-blocking concurrent list.
We are ...