Skip to content

Awadhesh-Gupta/ConcurrencyNdMultithreading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

markdown

Concurrency and Multithreading in Java

This repository contains Java programs that demonstrate concepts of Concurrency and Multithreading, including inter-thread communication, synchronization, and common producer-consumer scenarios.

πŸ“ Project Structure


ConcurrencyNdMultithreading/
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── src/
└── multithreadingClass/
β”œβ”€β”€ ProducerConsumerPrblm\_ImplmtngBlockingQueue.java
└── ThreadSleepInLoop.java

πŸ” Descriptions

1. ProducerConsumerPrblm_ImplmtngBlockingQueue.java

A custom implementation of a Blocking Queue to solve the classic Producer-Consumer problem using:

  • synchronized blocks
  • wait() and notifyAll() for inter-thread communication
  • Bounded queue behavior using a LinkedList with capacity limits

This file creates two threads:

  • Producer (Thread1) adds integers to the queue.
  • Consumer (Thread2) removes integers from the queue.

2. ThreadSleepInLoop.java

Demonstrates use of Thread.sleep() in a for loop to simulate thread execution delay and observe behavior over time.

βœ… Concepts Demonstrated

  • Java Thread Lifecycle
  • Synchronization with intrinsic locks
  • Inter-thread signaling using wait() and notifyAll()
  • Queue operations in concurrent context
  • Thread-safe design using intrinsic object monitor

πŸ›  How to Run

  1. Clone the repository:
    git clone https://github.com/Awadhesh-Gupta/ConcurrencyNdMultithreading.git
    cd ConcurrencyNdMultithreading

2. Compile the code:

   ```bash
   javac src/multithreadingClass/*.java
   ```

3. Run the main class:

   ```bash
   java -cp src multithreadingClass.ProducerConsumerPrblm_ImplmtngBlockingQueue
   ```

## πŸ“Œ Requirements

* Java 8 or higher
* Basic understanding of threads and synchronization

## πŸ“„ License

This project is open-source and available under the [MIT License](LICENSE).

---

Feel free to contribute or fork this repository to explore concurrent programming more deeply.

```

About

Learning Java Concurrency and Multithreading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages