Reputation: 9855
So I am using a fixed sized BlockingQueue [ArrayBlockingQueue] in a producer/consumer type application, but I want the user to be able to change the queue size on the fly. Problem is there is not a BlockingQueue implementation that allows changing capacity after creation. Anyone ever come across this before? Any ideas?
Upvotes: 14
Views: 5921
Reputation: 128307
The most obvious solution (may or may not be appropriate depending on your circumstances) would be to simply instantiate a new queue with the updated capacity you want. Then push everything from the old queue into the new queue.
Upvotes: 2
Reputation: 533530
You could extend LinkedBlockingQueue. Its limit is is a soft limit (i.e. just an additional check) and you could make this something you can change (by disabling the built in one and putting in your own)
Upvotes: 1