I have two separated blocking queues. The clients usually use either the first of the second blocking queue to retrieve elements to be processed.
In some case, the clients are interested in elements from the two blocking queues, whichever queue provides the data first.
How can a client wait for the two queues, in parallel?
You could try using the poll
method in some sort of loop to only wait a specified amount of time for one queue before polling the other one.
Other than that, I'd say running the blocking operations for each queue on separate threads and providing a callback interface to your main application is another, slightly more complex, option.