Description of the producer and consumer issues in Java:
Producer-Consumer (Producer-consumer) issues, also known as bounded buffer (bounded-buffer) issues, two processes share a common, fixed-size buffer (warehouse). One is the producer, used to put the product in the warehouse: the other is the consumer, used to remove the product from the warehouse consumption. The problem is that when the warehouse is full, and the producer wants to put a new product into it, the solution is to let the producer wait, waiting for the consumer to pick up one or more products from the warehouse before waking it up. Similarly, when the warehouse is empty, and consumers want to go to the warehouse to consume products, it can also allow consumers to wait, waiting for the producer to put in one or more products and then wake it up.
Producers and consumers need to make clear the following information:
1, the producer only in the storage is not full time production, warehouse full stop production.
2, producers in the production of consumable products, should inform the waiting consumers to spend.
3, consumers only in storage products can be consumed, Cang is waiting.
4, the consumer found that storage products can be consumed when the production will be notified to producers.
Demo:
Producer, consumer issues in Java