A collection of Java-based concurrency examples demonstrating thread synchronization, locks, and shared resource management.
This project explores various concurrency patterns and synchronization techniques in Java. It provides practical implementations of real-world scenarios where multiple threads must interact safely with shared resources. Each module focuses on a specific concurrency primitive, such as ReentrantReadWriteLock, Semaphore, and synchronized blocks, to ensure data integrity and prevent race conditions.
- 🏦 Bank Transaction System - Handles concurrent bank transfers using
ReentrantReadWriteLockfor safety. - ☕ Coffee Shop Simulation - A producer-consumer model managing coffee orders between Baristas and Customers.
- 🚻 Bathroom Stall Management - Demonstrates resource synchronization using
Semaphorefor shared stalls. - 🧵 Multi-threading - Deep dive into Java thread management, lifecycle, and synchronization.
- 🔒 Thread Safety - Implementation of locks and semaphores to prevent race conditions.
- 🚀 Concurrent Execution - High-performance simulation of real-world scenarios with multiple active threads.
| Layer | Technology |
|---|---|
| Language | Java |
| IDE | IntelliJ IDEA |
- Java Development Kit (JDK) v8 or higher
- Git
git clone https://github.com/PramudithaN/Concurrent-Programming.git
cd Concurrent-ProgrammingSimply open the project folder in IntelliJ IDEA. The IDE will recognize the .iml file and set up the modules automatically.
You can run the main methods in the following files:
- Scenario 1 (Coffee Shop):
src/CoffeeShop/CoffeeShopExample.java - Scenario 2 (Bank System):
src/BankTransactionSystem/Main.java - Scenario 3 (Floor Bathroom):
src/FloorBathroom/FloorBathroom.java
Concurrent-Programming/
├── src/
│ ├── BankTransactionSystem/ # Concurrent bank transfers with ReentrantReadWriteLock
│ │ ├── BankAccount.java
│ │ ├── Main.java
│ │ └── TransactionSystem.java
│ ├── CoffeeShop/ # Producer-Consumer model for coffee orders
│ │ ├── Barista.java
│ │ ├── CoffeeShop.java
│ │ ├── CoffeeShopExample.java
│ │ └── Customer.java
│ └── FloorBathroom/ # Semaphore-based shared resource access
│ └── FloorBathroom.java
├── Concurrent_CW.iml # IntelliJ IDEA module file
└── .gitignore # Git ignore rules
- GitHub: github.com/PramudithaN
- LinkedIn: linkedin.com/in/pramuditha-nadun-612b1b204
- Email: pramudithanadun@gmail.com
Developed with ❤️ by Pramuditha Nadun.