I have 2 threads.
each of them reads some data from a shared buffer.
currentDataBuffer.get(thisID); //currentDataBuffer is my shared buffer object
I want to block thread after every call, and release it when all thread read the buffer (once)
so I used this currentDataBuffer object as lock:
currentDataBuffer.get(thisID); synchronized (currentDataBuffer ) { currentDataBuffer.wait(); }
The problem is how can I release those threads?
inside currentDataBuffer I have a map where I store the ids of threads that read data from buffer.
how can I use this.notifyAll(); (from currentDataBuffer ) to wake up all locked threads?