I have to develop an application that is similar to the producer-consumer problem in java.
However I do not know a lot about java, and I have a couple of questions.
Both the producer and consumer that are different threads and they both need to access the same buffer. If they are both different classes (that either extends thread class or implement the runnable interface) how do I code them to use the exact same buffer (this supposed buffer is an array of a certain object)?
I also would like to read some suggestions about how the overall architecture and how should I implement them. I need to code them so that two threads don't consume the same buffer position at the same time, that two producer threads don't insert at the exact same value at the same time, producer can't insert a new item in an already filled buffer, and that no consumer should consume when the buffer is empty.
In this example there must be several consumers and several producers working at the same time.
I looked for some examples in java but they are all different of what I need.