The producer-consumer problem is one of the classical examples of synchronization. This program simulates a multi producer-consumer problem in C++(althrough most part is c).
Compiling the program: g++ filename.cpp -pthread
Running the program: ./a.out number_of_producers number_of consumers maximum_buffer_size