Cover by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required