Is LinkedBlockingQueue the right choice for a producer-consumer scenario?

I have a producer-consumer scenario. Class A creates objects of type E. Do I have to store it in a static data structure in class A, because the consumer logic should be processed in class B, which does not have a reference to object A. Is LinkedBlockingQueue the correct data type for the queue? Or is there a better choice for this?

+3
source share
2 answers

If you use a limited queue, you can also consider ArrayBlockingQueue.

Also from LinkedBlockingQueueJavadoc:

, .

+2

, , LinkedBlockingQueue<E> .

0

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


All Articles