Repeating Java BlockingQueue

So I use the fixed size BlockingQueue [ArrayBlockingQueue] in the producer / consumer application, but I want the user to be able to resize the queue on the fly. The problem is that the implementation of BlockingQueue does not allow changing the capacity after creation. Has anyone ever come across this before? Any ideas?

+6
source share
2 answers

The most obvious solution (it may or may not be appropriate depending on your circumstances) would be to simply create a new queue with updated bandwidth. Then pull everything from the old queue to the new queue.

+2
source

You can extend LinkedBlockingQueue. Its limit is a soft limit (i.e., just an additional check), and you can do it that you can change (by disabling the built-in one and placing your own).

+1
source

Source: https://habr.com/ru/post/892158/


All Articles