1Z0-805 · Question #9
Which two Capabilities does Java.util.concurcent.BlockingQueue provide to handle operation that cannot be handled immediately?
The correct answer is B. Wait for the queue to contain elements before retrieving an element. D. Wait for space to become available in the queue before inserting an element. 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…
Question
Which two Capabilities does Java.util.concurcent.BlockingQueue provide to handle operation that cannot be handled immediately?
Options
- AAutomatically retry access to the queue with a given periodicity.
- BWait for the queue to contain elements before retrieving an element.
- CIncrease the queue's capacity based on the rate of blocked access attempts.
- DWait for space to become available in the queue before inserting an element.
How the community answered
(25 responses)- A12% (3)
- B84% (21)
- C4% (1)
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.
Topics
Community Discussion
No community discussion yet for this question.