There's more...

The LinkedBlockingDeque class also provides methods to insert and get elements from the deque that, instead of being blocked, throws an exception or returns the null value. These methods are as follows:

  • takeFirst() and takeLast(): These return the first and last element of the deque, respectively. They remove the returned element from the deque. If the deque is empty, they block the thread until there are elements in the deque.
  • getFirst() and getLast(): These return the first and last element of the deque, respectively. They don't remove the returned element from the deque. If the deque is empty, they throw a NoSuchElementExcpetion exception.
  • peek(), peekFirst(), and peekLast(): The peekFirst() and peekLast() methods return ...

Get Java 9 Concurrency Cookbook - 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.