Using blocking thread-safe lists

The most basic collection is the list. A list has an undetermined number of elements and you can add, read, or remove the element from any position. A concurrent list allows 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 blocking lists in your concurrent programs. The main difference between blocking lists and non-blocking lists is that blocking lists has methods to insert and delete elements on it that, if they can't do the operation immediately, because the list is full or empty, they block the thread that make the call until the operation can be made. Java includes the LinkedBlockingDeque class that implements ...

Get Java 7 Concurrency Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.