markdown
This repository contains Java programs that demonstrate concepts of Concurrency and Multithreading, including inter-thread communication, synchronization, and common producer-consumer scenarios.
ConcurrencyNdMultithreading/
β
βββ .gitignore
βββ README.md
βββ src/
βββ multithreadingClass/
βββ ProducerConsumerPrblm\_ImplmtngBlockingQueue.java
βββ ThreadSleepInLoop.java
A custom implementation of a Blocking Queue to solve the classic Producer-Consumer problem using:
synchronizedblockswait()andnotifyAll()for inter-thread communication- Bounded queue behavior using a
LinkedListwith capacity limits
This file creates two threads:
- Producer (Thread1) adds integers to the queue.
- Consumer (Thread2) removes integers from the queue.
Demonstrates use of Thread.sleep() in a for loop to simulate thread execution delay and observe behavior over time.
- Java Thread Lifecycle
- Synchronization with intrinsic locks
- Inter-thread signaling using
wait()andnotifyAll() - Queue operations in concurrent context
- Thread-safe design using intrinsic object monitor
- 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.
```