There's more...

The ConcurrentLinkedDeque class provides more methods to get elements from the deque:

  • getFirst() and getLast(): These methods return the first and last element from 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(): These methods return the first and the last element of the deque, respectively. They don't remove the returned element from the deque. If the deque is empty, they return a null value.
  • remove(), removeFirst(), and removeLast(): These methods return the first and last element of the deque, respectively. They remove the returned element as well. If the deque is empty, they throw ...

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.