There's more...

The LinkedTransferQueue class provides other useful methods. The following are some of them:

  • getWaitingConsumerCount(): This method returns the number of consumers that are blocked in the take() method or poll (long timeout, TimeUnit unit) because the LinkedTransferQueue object is empty.
  • hasWaitingConsumer(): This method returns true if the LinkedTransferQueue object has consumers waiting, or false otherwise.
  • offer(E e): This method adds the element passed as a parameter at the end of the LinkedTransferQueue object and returns the true value. E represents the class used to parameterize the declaration of the LinkedTransferQueue class or a subclass of it.
  • peek(): This method returns the first element in the LinkedTransferQueue ...

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.