Which two Capabilities does Java.util.concurcent.BlockingQueue provide to handle operation that
cannot be handled immediately?
A.
Automatically retry access to the queue with a given periodicity.
B.
Wait for the queue to contain elements before retrieving an element.
C.
Increase the queue’s capacity based on the rate of blocked access attempts.
D.
Wait for space to become available in the queue before inserting an element.
Explanation:
A blocking queue is a Queue that additionally supports operations that wait for the
queue to become non-empty when retrieving an element, and wait for space to become available
in the queue when storing an element.
Note: The BlockingQueue interface in the java.util.concurrent class represents a queue which is
thread safe to put into, and take instances from.
The producing thread will keep producing new objects and insert them into the queue, until the
queue reaches some upper bound on what it can contain. It’s limit, in other words. If the blocking
queue reaches its upper limit, the producing thread is blocked while trying to insert the new object.
It remains blocked until a consuming thread takes an object out of the queue.
The consuming thread keeps taking objects out of the blocking queue, and processes them. If the
consuming thread tries to take an object out of an empty queue, the consuming thread is blocked
until a producing thread puts an object into the queue.
Reference: Java.util.concurcent.BlockingQueue