Producer Consumer problem explained...
Producer Consumer is the very basic problem of multithreading. If we are not familiar with the problem, let's dive into it straightaway. So as the wiki says (don't read it all, m going to explain.) "Producer Consumer problem is a classic example of a multi- process synchronization problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue . The producer's job is to generate data, put it into the buffer, and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer), one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer. " Okay, Example. 1. Assume you go to a party, you find plates over there, you pick up a plate and move towards the food buffet. but, what if you don't find a plate, you w...