![]() |
VOOZH | about |
The remainingCapacity() method of LinkedBlockingQueue returns the number of more elements that can be added to LinkedBlockingQueue without blocking. The Capacity returned arises three cases:
Syntax:
public int remainingCapacity()
Return Value: This method returns the remaining capacity of the LinkedBlockingQueue.
Below programs illustrates remainingCapacity() method of LinkedBlockingQueue class:
Program 1: Returning the remaining Capacity of the LinkedBlockingQueue using remainingCapacity() method where LinkedBlockingQueue contains list of names.
Queue is [John, Tom, Clark, Kat] Remaining Capacity of Queue is 3
Program 2: Finding Remaining Capacity of LinkedBlockingQueue which contains list of Employees.
Adding employee is success true Remaining Capacity of list :4 Adding employee is success true Remaining Capacity of list :3 Adding employee is success true Remaining Capacity of list :2 Adding employee is success true Remaining Capacity of list :1 Adding employee is success true Remaining Capacity of list :0