Reputation: 17
I am pretty new in writing Java and i'm currently trying to implement a different aspect of the classic "Producer-Consumer" problem. I still use one Producer like usual, who writes strings in a buffer. This buffer is shared with the 2 Consumer threads, and what I am trying to do is to have both the Consumers pick up EVERY string the producer sends, and ONLY then delete the string from the buffer. How can i check if both the Consumer threads have already taken the string??? Thank you!
Upvotes: 1
Views: 157
Reputation: 26
Maybe you can use the observer pattern.
More info: https://www.baeldung.com/java-observer-pattern
Upvotes: 1