I have a producer-consumer like scenario. Class A produces objects of type E. I have to hold it in a static data structure in class A, because the consumer logic should be handled in a class B, which has no reference to object of A. Is LinkedBlockingQueue the correct data type for the queue? Or are there any better selection for this?
If you are using a bounded queue, you could also consider an ArrayBlockingQueue.
Also, from the LinkedBlockingQueue Javadoc:
Linked queues typically have higher throughput than array-based queues but less predictable performance in most concurrent applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With