Blocking and non-blocking data structures

The Java Concurrency API provides two kinds of concurrent data structures:

  • Blocking data structures: This kind of data structure provides methods to insert and delete data on it that, when the operation cannot be done immediately (for example, you want to take an element and the data structure is empty), the thread that made the call will be blocked until the operation can be done
  • Non-blocking data structures: This kind of data structure provides methods to insert and delete data on it that, when the operation cannot be done immediately, returns a special value or throws an exception

Sometimes, we have a non-blocking equivalent for the blocking data structure. For example, the ConcurrentLinkedDeque ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.