Tagged articles
CountDownLatch
51 articles · Page 1 of 1
This article explains Java's CyclicBarrier synchronization utility, highlighting its reusability and callback support compared to CountDownLatch, and demonstrates its use in two examples: a basic three-thread barrier with a callback and a parallel array sum calculation where threads compute partial sums and aggregate at the barrier.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 6 min read

This article explains five Java thread communication methods—volatile flag, Object wait/notify, CountDownLatch, ReentrantLock with Condition, and LockSupport—with runnable code examples showing how each coordinates a producer thread adding items and a consumer thread triggered at the fifth addition.
ConcurrencyCountDownLatchJava
0 likes · 10 min read

This article explains Java's AbstractQueuedSynchronizer (AQS) core model using a service counter analogy, detailing how the state variable and CLH queue manage thread synchronization, the template method pattern separating queuing logic from acquisition rules, and how LockSupport.park/unpark enable efficient thread blocking and waking, illustrated with ReentrantLock and CountDownLatch examples.
AQSAbstractQueuedSynchronizerCLH Queue
0 likes · 7 min read

This article explains Java's CyclicBarrier through two practical examples: coordinating concurrent API stress tests and batch-importing one million Excel rows, then reveals a design flaw where the main thread participates in the barrier and shows how to separate concerns using CountDownLatch for cleaner batch processing.
API Stress TestingCountDownLatchCyclicBarrier
0 likes · 10 min read

This article explains the key differences between Java's CyclicBarrier and CountDownLatch, focusing on which threads wait, thread lifecycle after signaling, reusability, and a practical pressure-test example using CountDownLatch to simulate concurrent requests.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 8 min read

The article explains CountDownLatch's implementation as a thin wrapper over AQS, detailing how it overrides tryAcquireShared and tryReleaseShared with CAS for thread-safe countdown, and teaches a high-level-to-detail interview answering strategy.
AQSCASCountDownLatch
0 likes · 3 min read

This article explains Java's CountDownLatch synchronization tool using a meeting analogy, demonstrates its usage with a Java 17 code example simulating attendees arriving at a meeting, and describes a real-world batch translation scenario where the main thread waits for multiple concurrent translation tasks to complete.
Batch TranslationConcurrency PatternsCountDownLatch
0 likes · 7 min read

This article provides a line-by-line analysis of Java's AbstractQueuedSynchronizer (AQS), covering its CLH variant queue, CAS-based state management, exclusive and shared synchronization modes, Condition implementation, and core design decisions like CLH vs MCS and volatile vs synchronized.
AQSCASCLH Queue
0 likes · 22 min read


DabaoshiAug 19, 2026 · Backend Development
This article explains how Java's synchronization utilities—CountDownLatch, CyclicBarrier, Semaphore, Phaser, and Exchanger—solve coordination problems such as one‑time startup waits, repeated barrier synchronization, resource‑quota limiting, dynamic multi‑stage collaboration, and two‑thread data exchange, with concrete code examples and a full seckill‑system case study.
CountDownLatchCyclicBarrierExchanger
0 likes · 18 min read

This article explains four practical ways to determine when tasks submitted to a Java ExecutorService have finished—using Future's isDone/get, ExecutorService.invokeAll, CompletionService, and CountDownLatch—each with code examples and usage guidance.
CompletionServiceCountDownLatchExecutorService
0 likes · 8 min read

This article introduces LatchUtils, a lightweight Java utility that streamlines asynchronous task registration and waiting, compares it with manual CountDownLatch and CompletableFuture approaches, and demonstrates how it reduces boilerplate while keeping business logic clear and maintainable.
ConcurrencyCountDownLatchExecutorService
0 likes · 15 min read

This article explains why using Thread.sleep() in Java ExecutorService unit tests is unreliable and inefficient, and introduces three robust alternatives—Future.get(), CountDownLatch, and shutdown/awaitTermination—to ensure stable, performant testing of asynchronous WebSocket query scenarios.
ConcurrencyCountDownLatchExecutorService
0 likes · 13 min read

This article explains why using Thread.sleep() in Java ExecutorService unit tests is unreliable and inefficient, and introduces three robust alternatives—Future.get(), CountDownLatch, and shutdown/awaitTermination—to achieve stable and performant testing of asynchronous code.
CountDownLatchExecutorServiceFuture
0 likes · 13 min read

This article explains how to perform HTTP load testing using Postman, Apache Bench, JMeter, and Java concurrency classes such as CountDownLatch and Semaphore, providing step‑by‑step setup, configuration, and code examples for simulating high‑traffic scenarios.
Apache BenchCountDownLatchJMeter
0 likes · 8 min read

This article provides a comprehensive guide to Java's core concurrency utilities—including Fork/Join, CountDownLatch, CyclicBarrier, Semaphore, and Exchanger—explaining their principles, internal AQS implementation, practical usage patterns, performance optimizations, and complete code examples for real‑world scenarios.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 25 min read

This article explains the Java CountDownLatch utility, demonstrates its countdown synchronization mechanism with a lucky‑card‑collection scenario, provides a complete runnable example, and shows how the main thread waits for all worker threads to finish before proceeding to the lottery step.
ConcurrencyCountDownLatchJava
0 likes · 5 min read

This article walks through designing and implementing a Java multithreaded execution class for performance testing, covering thread‑pool creation, task coordination with CountDownLatch, start/stop control, and a complete demo that runs concurrent tasks with timed logging.
ConcurrencyCountDownLatchJava
0 likes · 10 min read

CountDownLatch and CyclicBarrier are two essential Java synchronization tools from java.util.concurrent, enabling threads to coordinate tasks; this guide explains their concepts, usage with code examples, advantages, disadvantages, and key differences, helping developers choose the right tool for thread coordination.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 10 min read

This article explains the purpose, basic methods, best‑practice usage, and typical scenarios of Java's CountDownLatch utility, providing code examples and a comparison with Thread.sleep to help developers synchronize multiple threads effectively.
CountDownLatchJavaMultithreading
0 likes · 9 min read

This article explores Java's thread communication techniques—including the basic wait/notify mechanism, advanced Lock and Condition usage, and the thread‑safe BlockingQueue—providing detailed explanations, producer‑consumer examples, and additional concurrency utilities like CountDownLatch, illustrating how to coordinate threads efficiently in multithreaded applications.
BlockingQueueConcurrencyCondition
0 likes · 18 min read

This article explains why thread execution order is nondeterministic and presents eight Java techniques—join, single‑thread executor, CountDownLatch, CyclicBarrier, Semaphore, synchronized with wait/notify, and Lock with Condition—to reliably enforce sequential execution, complete with clear code examples for each method.
ConcurrencyCountDownLatchExecutorService
0 likes · 13 min read

This article explains the purpose, typical usage scenarios, and provides concrete code demonstrations of Java's CountDownLatch and CompletableFuture, comparing their synchronization versus asynchronous capabilities and guiding developers on selecting the appropriate tool for effective multithreaded programming.
CompletableFutureConcurrencyCountDownLatch
0 likes · 6 min read

This article explains a subtle thread‑pool deadlock caused by parent‑child task interactions, demonstrates the issue with a reproducible demo, analyzes why the latch logic fails, and provides a practical solution of isolating thread pools to avoid false‑deadlock behavior in microservices.
CountDownLatchJavadeadlock
0 likes · 11 min read

This article demonstrates five Java thread‑communication approaches—using a volatile flag, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—each illustrated with complete code examples and explanations of their behavior and limitations.
ConcurrencyCountDownLatchJava
0 likes · 10 min read

This article explains five Java thread‑communication techniques—volatile variables, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—providing code examples and detailed explanations of how each method works and its synchronization behavior, including sample programs that add elements to a list, demonstrate notification timing, and show how locks are acquired and released.
ConcurrencyCountDownLatchJava
0 likes · 11 min read

This article compares five Java thread‑communication techniques—volatile flag, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—by presenting concrete code examples, explaining their underlying mechanisms, and discussing their advantages and drawbacks.
ConcurrencyCountDownLatchJava
0 likes · 13 min read

This article introduces the four essential Java concurrency utilities—CountDownLatch, CyclicBarrier, Semaphore, and Exchanger—explaining their functions, underlying principles, typical usage patterns, and practical scenarios such as thread synchronization, resource limiting, and data exchange in multithreaded applications.
CountDownLatchCyclicBarrierExchanger
0 likes · 7 min read

This article explains how to turn Java asynchronous invocations into synchronous ones by demonstrating five approaches—wait/notify, condition locks, Future, CountDownLatch, and CyclicBarrier—each illustrated with complete code examples and detailed execution flow.
CountDownLatchCyclicBarrierFuture
0 likes · 11 min read

This article compares several practical techniques—using isTerminated after shutdown, comparing task counts, employing CountDownLatch, maintaining a manual counter, and checking Future.isDone—to reliably determine when a Java ThreadPoolExecutor has completed all submitted jobs, complete with code examples and pros and cons for each method.
CountDownLatchFutureThreadPool
0 likes · 10 min read

This tutorial demonstrates four straightforward techniques—using join() in child threads, join() in the main thread, CountDownLatch, and a single‑thread executor—to reliably control Java thread execution order, each illustrated with clear code examples and expected output.
ConcurrencyCountDownLatchExecutorService
0 likes · 7 min read

This article explains four practical techniques—using isTerminated, comparing task counts, CountDownLatch, and CyclicBarrier—to reliably detect when a Java ThreadPoolExecutor has finished executing all submitted tasks, including code examples, advantages, disadvantages, and a summary of each method.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 12 min read

This article explores the inner workings of Java’s CountDownLatch from JDK 1.8, detailing its core concepts such as the counter, thread synchronization, shared mode, and AQS mechanisms, and demonstrates practical usage through step‑by‑step code analysis and examples.
AQSConcurrencyCountDownLatch
0 likes · 5 min read

An overview of Java’s three primary thread‑synchronization tools—CountDownLatch, CyclicBarrier, and Phaser—explaining their placement in java.util.concurrent, typical use‑cases such as coordinating multi‑threaded tasks in performance testing, and the advantages of each, complemented by illustrative diagrams.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 7 min read

This article provides a comprehensive overview of Java's core concurrency utilities—CyclicBarrier, CountDownLatch, Semaphore, and Exchanger—explaining their purposes, internal mechanisms, constructors, usage patterns, and code examples to help developers master multithreaded programming.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 11 min read


政采云技术Oct 22, 2021 · Fundamentals
This article explains three Java concurrency tools - CountDownLatch, CyclicBarrier, and Semaphore - detailing their mechanisms, source code analysis, and practical usage scenarios with code examples.
AQSCountDownLatchCyclicBarrier
0 likes · 13 min read

This article explains how to replace slow single‑threaded API calls with a fixed‑size Java thread pool combined with CountDownLatch or Phaser for synchronization, achieving a ten‑to‑twenty‑fold performance boost while controlling request pressure.
ConcurrencyCountDownLatchJava
0 likes · 4 min read

This article explains the purpose, usage, and real‑world scenarios of Java’s CountDownLatch and CyclicBarrier synchronization aids, illustrating their behavior with relatable analogies and providing guidance on when to apply each construct in multithreaded applications.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 4 min read

CountDownLatch is a one‑time synchronization aid that blocks threads until a set of operations complete, illustrated with usage scenarios, a TestHarness example, and a deep dive into its internal implementation using AbstractQueuedSynchronizer, including code snippets and a flow diagram.
AQSConcurrencyCountDownLatch
0 likes · 10 min read

This article explains four Java concurrency utilities—CountDownLatch, CyclicBarrier, Semaphore, and Exchanger—detailing their concepts, typical use cases, and providing complete code examples that demonstrate synchronization patterns such as thread coordination, resource limiting, and data exchange.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 13 min read

This article explains Java’s concurrency utilities CountDownLatch, CyclicBarrier, Semaphore, and Exchanger, illustrating their concepts with race‑style analogies, providing complete code examples, and showing execution results to demonstrate how threads can synchronize, wait, limit, and exchange data.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 12 min read

This article explains the concept, practical usage, internal implementation, and key methods of Java's CyclicBarrier, compares it with CountDownLatch, and provides a complete code example demonstrating how multiple threads can repeatedly synchronize at a reusable barrier.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 8 min read

This article explains the concept of Java's CountDownLatch, compares it with join(), demonstrates how to coordinate thread‑pool tasks using the latch, provides complete example code, and details its internal mechanism and common methods for synchronizing concurrent operations.
ConcurrencyCountDownLatchJava
0 likes · 8 min read

This article explains how Java's CountDownLatch, CyclicBarrier, and Phaser classes work, compares their features, and shows practical scenarios—especially in performance testing—where each synchronization tool can be applied effectively.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 4 min read

This article introduces Java's CountDownLatch synchronization tool, explains its purpose as a gate or counter, demonstrates basic and advanced usage with code examples—including a simple counter and a student race scenario—and provides an in‑depth analysis of its underlying AQS‑based source code.
AQSConcurrencyCountDownLatch
0 likes · 15 min read

This article explains how to enforce a specific execution order among three Java threads—first thread 1, then thread 2, and finally thread 3—using four techniques: the join method, CountDownLatch, a single‑thread executor, and CompletableFuture, each illustrated with complete code examples.
CompletableFutureConcurrencyCountDownLatch
0 likes · 6 min read

This article explains Java’s CountDownLatch class, covering its package location, constructor, essential await and countDown methods, and demonstrates practical integration within a multithreaded performance testing framework, including sample code for task execution, thread management, and cleanup.
ConcurrencyCountDownLatchJava
0 likes · 5 min read

This article explains how to improve the performance of multi‑query server interfaces by converting asynchronous calls to synchronous execution using Spring's @Async annotation and CountDownLatch, outlining suitable scenarios, providing Java pseudocode, and sharing practical implementation tips.
CountDownLatchJavaSpring
0 likes · 7 min read

This article explores the evolution of parallel computing in Java, explaining why single‑core performance stalls, how multi‑core CPUs and GPUs enable true concurrency, and demonstrating practical implementations using CountDownLatch, CompletableFuture, Fork/Join, parallel streams, and sharding, while highlighting performance considerations and pitfalls.
CompletableFutureCountDownLatchForkJoinPool
0 likes · 15 min read

This article explains the purpose, differences, internal structure, and core methods of Java's CountDownLatch, shows how it leverages AQS for shared lock semantics, and provides a complete example demonstrating its usage in a thread‑synchronization scenario.
AQSConcurrencyCountDownLatch
0 likes · 8 min read

This article explains how to achieve thread communication and coordination in Java using Thread.join(), Object.wait()/notify(), CountDownLatch, CyclicBarrier, and the Callable/FutureTask pair, providing complete code examples and execution results for each technique.
CountDownLatchCyclicBarrierFutureTask
0 likes · 14 min read

This article explains how CountDownLatch and CyclicBarrier work in Java, illustrates their usage with practical Dragon‑Ball analogies, compares their features, and provides code snippets and real‑time system scenarios to help developers synchronize threads effectively.
ConcurrencyCountDownLatchCyclicBarrier
0 likes · 8 min read
