Java ArrayBlockingQueue offer() MethodThe offer() method of Java ArrayBlockingQueue class adds the defined element at the tail of this queue, only if the queue is not full or it waits till the specified wait time for space to get free, if the queue is full. Syntax:Parameters:e - This is the element to be added. timeout - This is the time to wait before giving up(in units of unit). unit - This is the TimeUnit deciding how to represent the timeout parameter. Specified By:The offer() method of ArrayBlockingQueue class is specified by:
Throws:The offer() method throws:
Return Value:The offer() method returns true on successful insertion, otherwise returns false. Or The offer() method returns true on successful insertion, or false if the assigned waiting time passes before space is available. Example 1Output: 567 56 5671 5167 5670 Example 2Output: Reema Rahul Rita Ramesh Example 3Output: Reema Panda [email protected] Geetanjali Sharma [email protected] Vineet Tanjea [email protected] Himanshu Bhardwaj [email protected] Next TopicJava-arrayblockingqueue-peek-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