Java ArrayBlockingQueue poll() MethodThe poll() method of ArrayBlockingQueue class retrieves the head of this queue awaiting till the specified time if essential for an element to be available, and also removes it. The method returns null if this queue is empty. Syntax:Parameters:
Specified By:The poll() method of ArrayBlockingQueue class is specified by poll() method in interface Queue<E>. Return Value:The poll() method returns this queue's head, or null if this queue is empty or if the assigned waiting time passes before element is available. Throws:The poll() method throws: InterruptedException - if method is disrupted while waiting. Example 1Output: Head of queue is : Reema Elements left in queue : [Rahul, Rita, Ramesh] Example 2Output: Head of queue : 67 Elements in queue : [109, 76, 876] Example 3Output: Reema gets the highest wages of 12000 Geetanjali gets the second highest wages of 4500 Next TopicJava-arrayblockingqueue-put-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India