Implement a synchronization mechanism using mutexes and condition variables to solve the producer-consumer problem.