Circular Buffer with Threads Consumer and Producer: it get stucks some executions
问题 I'm developing a circular buffer with two Threads: Consumer and Producer. I'm using active waiting with Thread.yield . I know that it is possible to do that with semaphores, but I wanted the buffer without semaphores. Both have a shared variable: bufferCircular . While the buffer is not full of useful information, producer write data in the position p of array, and while there are some useful information consumer read data in the position c of array. The variable nElem from BufferCircular is