Producer, consumer issues in Java

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.