O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition 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

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

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