{"id":51015720,"url":"https://github.com/madmmas/java-concurrency-interview-practice","last_synced_at":"2026-06-21T10:02:15.460Z","repository":{"id":362821155,"uuid":"1259122244","full_name":"madmmas/java-concurrency-interview-practice","owner":"madmmas","description":"50 structured Java concurrency problems — beginner to expert — with JUnit 5 tests. Interview prep \u0026 hands-on learning.","archived":false,"fork":false,"pushed_at":"2026-06-18T11:05:44.000Z","size":272,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-18T11:24:58.946Z","etag":null,"topics":["concurrency","data-structures","interview-prep","java","java-concurrency","junit5","locking","maven","multithreading","thread-safety"],"latest_commit_sha":null,"homepage":"https://madmmasblog.vercel.app","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madmmas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-04T08:01:26.000Z","updated_at":"2026-06-18T11:05:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/madmmas/java-concurrency-interview-practice","commit_stats":null,"previous_names":["madmmas/java-concurrency-interview-practice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/madmmas/java-concurrency-interview-practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmmas%2Fjava-concurrency-interview-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmmas%2Fjava-concurrency-interview-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmmas%2Fjava-concurrency-interview-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmmas%2Fjava-concurrency-interview-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madmmas","download_url":"https://codeload.github.com/madmmas/java-concurrency-interview-practice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmmas%2Fjava-concurrency-interview-practice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34605335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","data-structures","interview-prep","java","java-concurrency","junit5","locking","maven","multithreading","thread-safety"],"created_at":"2026-06-21T10:02:14.747Z","updated_at":"2026-06-21T10:02:15.454Z","avatar_url":"https://github.com/madmmas.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ☕ Java Concurrency \u0026 Threads — Practice Problem Sets\n\nA structured collection of **50 Java concurrency problems** organized by difficulty, both interview preparation and hands-on learning.\n\n---\n\n## 📚 Structure\n\n```\njava-concurrency-practice/\n├── beginner/       # Problems 01–15  (Foundations)\n├── intermediate/   # Problems 16–25  (Core Concurrency APIs)\n└── advanced/       # Problems 26–35  (Core advanced patterns)\n└── expert/         # Problems 36–50  (Deep systems design)\n```\n\nEach problem folder contains:\n- `README.md` — Problem description, concepts covered, hints\n- `src/main/java/` — Skeleton class(es) for you to implement\n- `src/test/java/` — JUnit 5 tests to validate your solution\n\n---\n\n## 🗺️ Problem Index\n\n### 🟢 Beginner (01–15)\n| # | Problem | Key Concept |\n|---|---------|-------------|\n| 01 | Thread Basics | `Thread` class, `start()`, `run()` |\n| 02 | Runnable vs Thread | `Runnable`, lambda threads |\n| 03 | Synchronized Counter | `synchronized`, race conditions |\n| 04 | Producer-Consumer Basic | `wait()`, `notify()` |\n| 05 | Thread Join | `join()`, ordering guarantees |\n| 06 | Volatile Keyword     | Memory visibility, JMM, stop-flags |\n| 07 | Daemon Threads       | Daemon vs user threads, background services |\n| 08 | Thread Interruption  | Cooperative cancellation, `InterruptedException` |\n| 09 | AtomicInteger \u0026 CAS  | Lock-free programming, Compare-And-Swap |\n| 10 | ThreadLocal          | Per-thread storage, memory-leak pitfall |\n| 11 | ReentrantLock | Explicit locking, `Condition`, deadlock-free transfer |\n| 12 | ReadWriteLock | Concurrent reads, exclusive writes, lock downgrading |\n| 13 | CountDownLatch | Startup gate, starting-gun pattern, timed await |\n| 14 | Thread-Safe Singleton | Eager / Synchronized / DCL+volatile / Holder |\n| 15 | FizzBuzz Threads | 4-thread coordination with wait/notifyAll |\n\n### 🟡 Intermediate (16–25)\n| # | Problem | Classes | Core Concept |\n|---|---------|---------|-------------|\n| 16 | Semaphore            | `ConnectionPool`, `RateLimiter`         | Permits, bounded concurrency, token-bucket |\n| 17 | CyclicBarrier        | `ParallelMatrixMultiplier`, `PhaseSimulator` | Reusable barrier, barrier action, phased execution |\n| 18 | ExecutorService      | `TaskDispatcher`, `PrioritizedExecutor` | ThreadPoolExecutor, CallerRunsPolicy, PriorityBlockingQueue |\n| 19 | Future \u0026 Callable    | `AsyncTaskRunner`, `CompletablePipeline` | Future.get(), timeout, first-completed, CompletableFuture chaining |\n| 20 | ForkJoinPool         | `ParallelSum`, `ParallelMergeSort`, `ParallelSearch` | RecursiveTask, RecursiveAction, work-stealing, divide-and-conquer |\n| 21 | BlockingQueue Deep Dive   | `WorkStealingPipeline`, `DelayedTaskScheduler` | Poison-pill shutdown, `DelayQueue`, `Delayed` interface |\n| 22 | Exchanger                 | `DoubleBufferedLogger`, `GeneticCrossover`    | Bidirectional handoff, double-buffering pattern |\n| 23 | Phaser                    | `DynamicWorkerPool`, `PipelinedDataProcessor` | Dynamic registration, `onAdvance`, `arriveAndDeregister` |\n| 24 | StampedLock               | `OptimisticPoint`, `StampedCache`             | Optimistic reads, `validate()`, `tryConvertToWriteLock` |\n| 25 | ConcurrentHashMap         | `WordFrequencyCounter`, `ConcurrentInventory` | `merge`, `compute`, `replace` CAS loop, parallel bulk ops |\n\n### 🔴 Advanced (26–35)\n| #  | Problem                  | Skeleton Classes                                          | Core Concept                                      |\n|----|--------------------------|-----------------------------------------------------------|---------------------------------------------------|\n| 26 | Lock-Free Data Structures| `TreiberStack`, `LockFreeQueue`, `ABADemonstrator`        | CAS retry loops, sentinel node, ABA problem       |\n| 27 | Java Memory Model        | `SafePublicationShowcase`, `HappensBeforeChain`, `MemoryVisibilityProbe` | happens-before rules, safe publication, volatile |\n| 28 | Deadlock Detection       | `ResourceAllocationGraph`, `DeadlockPreventer`, `DeadlockDemo` | RAG cycle detection, lock ordering, tryLock, ThreadMXBean |\n| 29 | ScheduledExecutorService | `TaskScheduler`, `CircuitBreaker`                         | scheduleAtFixedRate vs fixedDelay, circuit breaker state machine |\n| 30 | Custom ThreadPoolExecutor| `InstrumentedThreadPool`, `WorkerThreadFactory`, `BoundedCallerRunsPool` | hook methods, ThreadLocal latency, CallerRunsPolicy |\n| 31 | Async Pipeline | `AsyncOrderProcessor`, `PipelineMerger`, `Order` | `thenCompose`, `thenCombine`, `allOf`, `anyOf`, `exceptionally`, fan-out/fan-in |\n| 32 | Work-Stealing Deque | `WorkStealingDeque\u003cT\u003e`, `WorkStealingScheduler` | Owner LIFO pop, thief FIFO steal, circular array, grow(), ForkJoinPool internals |\n| 33 | STM Simulation | `TVar\u003cT\u003e`, `Transaction`, `STM` | Optimistic concurrency, versioned reads, commit/retry protocol, composable atomicity |\n| 34 | Actor Model | `Actor\u003cS,M\u003e`, `BankAccountActor`, `ActorSystem`, `PingPongActors` | Message-passing, mailbox, tell/ask, fire-and-forget vs request-reply, no shared state |\n| 35 | Concurrent Skip List | `ConcurrentSkipListSet` (lock-based), `LockFreeSkipListSet` (lock-free), `SkipListBenchmark` | O(log n) probabilistic structure, hand-over-hand locking, AtomicMarkableReference, logical deletion, linearisability |\n\n### 🔴 Expert (36–50)\n| # | Problem | Key Concept |\n|---|---------|-------------|\n| 36 | Reactive Streams | Flow.Publisher/Subscriber, back-pressure, TransformProcessor |\n| 37 | Distributed Counter | StripedCounter, LongAdder, MetricsCollector |\n| 38 | Priority Task Executor | PriorityBlockingQueue, PriorityTask, FIFO tie-breaking |\n| 39 | Concurrent LRU Cache | LinkedHashMap accessOrder, ReadWriteLock |\n| 40 | Thread-Safe Object Pool | LinkedBlockingQueue, AutoCloseable borrow/return |\n| 41 | Custom Barrier | ReentrantLock+Condition, generation counter, BrokenBarrierException |\n| 42 | Async Event Bus | ConcurrentHashMap, CopyOnWriteArrayList, class hierarchy dispatch |\n| 43 | Concurrent Graph Traversal | Parallel BFS (ExecutorService), Parallel DFS (ForkJoinPool) |\n| 44 | Rate-Limited Executor | Token bucket (lazy refill), tryAcquire with timeout |\n| 45 | Lock-Free Ring Buffer | SPSC volatile head/tail, MPSC AtomicLong+ready flags |\n| 46 | Concurrent Trie | computeIfAbsent, volatile isEnd, DFS collect |\n| 47 | 2PC Transaction Manager | Parallel prepare/commit/rollback, ExecutorService |\n| 48 | Thread Confinement Pool | ThreadLocal, DateFormatterPool, ConfinedWorkerPool |\n| 49 | Parallel Merge Sort Advanced | ForkJoinPool, RecursiveAction, adaptiveThreshold, binarySearch |\n| 50 | Mini Job Scheduler (Capstone) | Priority queue, token bucket, metrics, graceful shutdown |\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n- Java 11+\n- Maven 3.6+ \n- ⚠️ Java 17 required — Problems 34 and 35 use sealed interface and record types. Update your root pom.xml compiler target to 17:\n\n```xml\n\u003cmaven.compiler.source\u003e17\u003c/maven.compiler.source\u003e\n\u003cmaven.compiler.target\u003e17\u003c/maven.compiler.target\u003e\n```\n\n### Run Tests for a Single Problem\n```bash\ncd beginner/01-thread-basics\nmvn test\n```\n\n---\n\n## 💡 How to Use This Repo\n\n1. Read the `README.md` inside each problem folder\n2. Open the skeleton class in `src/main/java/`\n3. Implement the solution — **do not modify the test files**\n4. Run `mvn test` to verify\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadmmas%2Fjava-concurrency-interview-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadmmas%2Fjava-concurrency-interview-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadmmas%2Fjava-concurrency-interview-practice/lists"}