AT&T Interview Question

Producer/consumer type problem.