How is the recommended way of terminating multiple threads that are blocked in java.util.concurrent.BlockingQueue put/take operations?
Assume that we have multiple producers and consumers executing in separate threads that are started independently. An unknown number of producers are locked in blocking calls to put() and an unknown number of consumers are locked in calls to take(). I don't have control of all the producers/consumers due to various reasons. At some time the queue should be closed so all pending put/take calls should be interrupted. How is this done?
It would be nice if there were a BlockingQueue.close() method or something similar to release all blocked threads.