Can ConcurrentLinkedDeque have a fixed size and overwrite old elements?
Can ConcurrentLinkedDeque have a fixed size and overwrite old elements? If I got this right ConcurrentLinkedDeque acts as a stack right if you use pollLast() ? pollLast() Now my issue is that I need a set size of ConcurrentLinkedDeque. My producer doesn't stop, so even if I have 16GB of ram I will run out eventually. SO is it possible to se a fixed size ? My implementation: ConcurrentLinkedDeque<String> queue = new ConcurrentLinkedDeque<>(); Producer (Thread 1): runs queue.add(line); Consumer (Thread 2): runs queue.pollLast(); queue.add(line); queue.pollLast(); Please note that both threads run in a while true loop . This is because of the requirements. That is why I am using ConcurrentLinkedDeque and not ArrayBlockingQueue or SynchronousQueue because it is non-blocking. ConcurrentLinkedDeque ArrayBlockingQueue SynchronousQueue Also do I need to declare anything synchronised ? synchronised Use a fixed size BlockingQueue which would all...