Thread Safety Issue in DataQueue add() and poll() Methods
ad-kmt opened this issue · 0 comments
ad-kmt commented
The DataQueue
class in the Producer-Consumer implementation uses a LinkedList
to implement the queue, which is not thread-safe. Additionally, the add()
and poll()
methods of DataQueue
are not synchronized. I feel this can lead to race conditions, data corruption, and visibility issues when multiple threads concurrently access the queue.
Kindly correct me if I'm wrong, Thanks!
Article: https://www.baeldung.com/java-producer-consumer-problem