I would like to create a circular buffer that will have two indexes:
- WriteIndex (controlled by the first thread) to write a new value in the buffer
- ReadIndex (controlled by the second thread) to read the value from the buffer and parse it
So, how can I pause Thread when two indexes are in the same position. I mean, if you did not write any new data, you cannot read it, so if writeindex and readindex are in the same position, you only need to write new data, not read.
How to block a thread until something happens?
source
share