Let’s spend some time on FIFO queue construction. A FIFO is a First In First Out queue. There are two methods of manipulation. The first is general purpose, in that it will work with any number of readers (consumers) and writers (producers). It does require a lock (also called a mutex or semaphore) to prevent concurrent threads from corrupting global data.
The second FIFO queue method does not employ locking; therefore it can only be used in the case of a single reader and writer. The trick to this new implementation is that we allow one slot in the queue to be wasted.