Skip to content

elmadaniabdelhamid/The-bounded-buffer-problem

Repository files navigation

Producer-Consumer with JAVA

Table of Contents

Overview

This project demonstrates the classic Producer-Consumer problem using Java. The Producer-Consumer problem is a synchronization problem that involves ensuring that producers (who produce data and add it to a buffer) and consumers (who take data from the buffer) operate without running into race conditions. This project uses Java's synchronized methods. It features a graphical user interface (GUI) to simulate the production and consumption of products.

Features

  • Producers can add data to the buffer while there is an empty scpace .
  • Consumers can consume data from the buffer if they exist.
  • The GUI allows users to:
    • Add new producer.
    • Add new consumer.
    • Remove a producer.
    • Remove a consumer.
    • View the number of producer and consumer existe.

Installation and Setup

Cloning the Repository

  1. Open a terminal or command prompt.

  2. Clone the repository using the following command:

    git clone https://github.com/yourusername/producer-consumer-java.git
    cd producer-consumer-java

install JDK

   sudo apt update
   sudo apt install default-jdk

Compiling the Project

  1. Navigate to the project directory:

    cd producer-consumer-java
  2. Compile the project:

    make

Running the Project

  1. Run the project:

    make run

Cleanin the project

  make clean

Troubleshooting

Common Issues

  1. Buffer Full or Empty:
    • If the buffer is full, producing a new data will fail, and a message will be displayed.
    • If the buffer is empty, consuming a data will fail, and a message will be displayed.

Contact

For further assistance, please contact: