The
poll() method of
ConcurrentLinkedQueue is used to remove and return the head of this ConcurrentLinkedQueue. If the ConcurrentLinkedQueue is empty then this method will return null.
Syntax:
public E poll()
Returns: This method remove and returns the
head of this ConcurrentLinkedQueue or
null if this queue is empty.
Below programs illustrate poll() method of ConcurrentLinkedQueue:
Example 1:
Output:
ConcurrentLinkedQueue: [4353, 7824, 78249, 8724]
Head: 4353
Current ConcurrentLinkedQueue: [7824, 78249, 8724]
Example 2: