Lenovo Interview Question

Fix this producer-consumer code to work well without any deadlocks.