It covers some basic concurrent programs as well as parallel program examples. Interview level material.
This project contains Java examples organized into three main categories:
- SumTask.java - Basic sum computation with single and multi-threaded approaches
Basic concurrency problems and solutions:
- UnisexBathroom.java - Unisex bathroom problem solution
- UberSeatingProblem.java - Uber seating arrangement concurrency problem
- DinningPhilosophers.java - Dining philosophers problem solution
- BarberShopProblem.java - Sleeping barber problem implementation
- Superman.java - Superman problem implementation
- MultiThreadedMergeSort.java - Parallel merge sort for interviews
- PrintNumberSeries.java - Threaded number series printing
- FizzBuzz.java - Multi-threaded FizzBuzz implementation
- SynchronousExecutor.java - Custom synchronous executor service
- DefferedCallbackExecutor.java - Deferred callback execution system
- BoundedBuffer.java - Basic bounded buffer implementation
- BoundedBufferWithMutex.java - Bounded buffer using mutex locks
- BoundedBufferWithSemaphore.java - Bounded buffer using semaphores
Fundamental concurrency concepts and thread management examples:
- CountDownLatchExample.java - Demonstrates CountDownLatch usage for coordinating multiple threads
- CustomThreadExecutorExample.java - Shows how to create custom thread executors
- CyclicBarrierExample.java - Illustrates CyclicBarrier for thread synchronization
- FixedThreadPoolExecutor.java - Implementation of fixed-size thread pool
- Simple.java - Basic threading concepts
- SumTaskCallable.java - Callable implementation for parallel sum computation
- ThreadLocalExample.java - ThreadLocal variable usage demonstration
- TimerExample.java - Timer and scheduled task examples
Practical parallel programming exercises:
- MatrixMultiplySolution.java - Parallel matrix multiplication implementation
- MergeSort.java - Concurrent merge sort algorithm
- Thread Management: Thread creation, pooling, and lifecycle management
- Synchronization: Locks, semaphores, monitors, and condition variables
- Concurrent Collections: Thread-safe data structures
- Executor Framework: Thread pools and task execution
- Classical Problems: Producer-consumer, dining philosophers, sleeping barber
- Parallel Algorithms: Merge sort, matrix multiplication
- Coordination Primitives: CountDownLatch, CyclicBarrier, ThreadLocal
Each Java file can be compiled and run independently. Most examples include a main method demonstrating the concept.
# Compile and run a specific example
javac src/main/java/basic/CountDownLatchExample.java
java -cp src/main/java basic.CountDownLatchExample- Java 8 or higher
- Basic understanding of multithreading concepts