Tagged articles
Semaphore
74 articles · Page 1 of 1
This article explains Java Semaphore's core decoupling property—where any thread can acquire or release permits—contrasting it with ReentrantLock's thread-owned locking, demonstrates with Java 17 code examples, and shows real-world rate-limiting applications in Sentinel, Dubbo, and Tomcat.
ConcurrencyDecouplingJava
0 likes · 8 min read

After upgrading to Java 25 and Spring Boot 4, the author enabled virtual threads and removed custom thread pools for IO-heavy aggregation endpoints. While code simplified dramatically, the bottleneck shifted from thread exhaustion to HikariCP connection pool exhaustion, revealing that virtual threads don't increase downstream capacity. The solution: limit scarce resources (DB connections, HTTP clients) directly rather than limiting threads.
ConcurrencyHikariCPIO-bound
0 likes · 12 min read

This article explains the classic Dining Philosophers deadlock problem, illustrates why naive locking causes deadlock with code, and presents five solutions—waiter semaphore, odd-even ordering, atomic acquisition, resource hierarchy, and monitor—each with pseudocode, trade-offs, and real-world analogies like database connection pools.
ConcurrencySemaphoreSynchronization
0 likes · 12 min read

This article provides a comprehensive source-code-level analysis of Java's AbstractQueuedSynchronizer (AQS), detailing its three core components—state, CLH wait queue, and ConditionObject—and walking through exclusive lock acquisition/release, fair vs non-fair locking, shared lock propagation, and condition variable await/signal mechanics with code examples.
AQSCLH QueueJava Concurrency
0 likes · 37 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

The article explains how sharing a single thread pool can cause a slow downstream service to cripple an entire high‑traffic system, compares thread‑pool and semaphore isolation—detailing their strengths, costs, and suitable scenarios—and provides practical guidelines, framework support, and design decisions for implementing robust isolation in microservices.
Circuit BreakerResilienceSemaphore
0 likes · 21 min read

The article examines how Java 21’s cheap virtual threads change the role of traditional thread pools, explaining why pooling virtual threads is a bad idea, how thread pools still act as natural throttlers, and which scenarios—especially CPU‑bound work and synchronized blocks—remain unsuitable for virtual threads.
ConcurrencyJDK 21Java
0 likes · 8 min read

This article provides a self‑test for interview preparation, presenting twelve common interview questions and detailed answers on an e‑commerce concurrency case, covering serial vs async performance, CompletableFuture.allOf, ConcurrentHashMap.compute atomicity, layered cache design, Semaphore rate limiting, ReentrantLock fairness, AtomicInteger CAS, exceptional fallback, double‑layer protection, concurrency safety testing, thread‑pool configuration, and precise cache invalidation.
CacheCompletableFutureConcurrency
0 likes · 21 min read

This comprehensive guide explains why race conditions occur in Linux processes, explores the underlying concepts of critical sections and synchronization, and provides practical examples of atomic operations, mutexes, semaphores, condition variables, read‑write locks, and spinlocks to ensure safe concurrent programming.
C++MutexPOSIX
0 likes · 39 min read

This article explores Java’s advanced lock mechanisms—ReentrantLock, ReentrantReadWriteLock, StampedLock, and Semaphore—detailing their core features, practical code examples, and ideal usage scenarios, helping developers decide which synchronization tool best fits their performance and concurrency requirements.
ConcurrencyJavaLocks
0 likes · 9 min read

This article explains the purpose, actions, and common types of locks in iOS—including spin locks, mutexes, semaphores, and read‑write locks—provides practical code examples, discusses underlying principles such as busy‑waiting and priority inversion, and compares performance across different lock implementations.
LocksMultithreadingSemaphore
0 likes · 18 min read

This article explains how to create three Java threads that print the characters A, B, and C in strict order, repeat the sequence twenty times, and demonstrates three implementations—unordered printing, ordered printing with Semaphore, and a looped version—complete with full source code examples.
ConcurrencyJavaMultithreading
0 likes · 7 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 Java's Semaphore concurrency primitive, its core methods, fair vs. non‑fair modes, typical scenarios such as rate limiting and resource pooling, and provides two complete code examples demonstrating thread coordination and download throttling.
ConcurrencyJavaMultithreading
0 likes · 6 min read

The article explains how Hystrix uses thread‑pool and semaphore isolation to prevent cascading failures in microservice architectures, detailing implementation, configuration defaults, suitable scenarios, and recommendations for building resilient distributed systems.
HystrixResilienceSemaphore
0 likes · 5 min read

This comprehensive guide explores why locks are essential in concurrent programming, explains the principles behind mutexes, semaphores, read‑write locks, and re‑entrant locks, provides Python code examples, discusses common pitfalls like deadlocks, and offers best‑practice strategies for production environments.
ConcurrencySemaphoreSynchronization
0 likes · 22 min read

This tutorial explains how to containerize a simple Go web application with Docker, set up a development workflow using Docker and Bee, build and run images, and automate continuous integration and deployment with Semaphore, covering prerequisites, Dockerfile creation, testing, and production deployment steps.
ContainerizationDockerGo
0 likes · 23 min read

This article explains how to print numbers from 1 to 100 with two Java threads—one handling odd numbers and the other even numbers—by first using a synchronized block with wait/notify and then by employing Semaphore for thread coordination.
JavaMultithreadingSemaphore
0 likes · 5 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 how to use Python's asyncio library to synchronize and communicate between coroutines, covering Event, Lock, Semaphore, Condition, and Queue primitives with clear code examples demonstrating each mechanism in practice.
ConditionEventLock
0 likes · 8 min read

This article provides a comprehensive overview of Linux thread synchronization, explaining core concepts such as mutexes, condition variables, semaphores, and futexes, describing their implementation details, code examples, and common usage scenarios like producer‑consumer and reader‑writer problems.
LinuxMutexSemaphore
0 likes · 33 min read

This article explains how a PHP script uses a named semaphore for process mutual exclusion, demonstrates why a second concurrent process can acquire the semaphore after the first finishes, and clarifies that PHP automatically releases held semaphores when a process terminates.
BackendConcurrencyPHP
0 likes · 3 min read

This article details the end‑to‑end architecture and step‑by‑step performance tuning of a high‑traffic lottery platform, covering server‑level rate limiting, application‑level throttling, semaphore usage, user‑behavior detection, caching strategies, database optimizations, and hardware upgrades that together enabled stable handling of millions of daily requests.
Semaphorebackend architecturedatabase scaling
0 likes · 15 min read

This article explains the design, principles, and C implementations of Linux kernel synchronization primitives—including spinlocks, semaphores, read‑write locks, and mutexes—illustrated with real‑world analogies, code snippets, and usage constraints in interrupt and multi‑CPU contexts.
LinuxMutexSemaphore
0 likes · 22 min read

The article explains how to ensure data correctness in Linux inter‑process shared memory communication by using synchronization mechanisms—semaphores, mutexes, and condition variables—providing step‑by‑step code examples for each method and discussing their proper initialization, usage, and potential pitfalls.
C++IPCLinux
0 likes · 15 min read

This article dissects RocketMQ's concurrency mechanisms, explaining why it uses ReentrantReadWriteLock with HashMaps, how Semaphore controls async send rates, the SemaphoreReleaseOnlyOnce wrapper, the CountDownLatch‑based sync‑to‑async pattern, and the CompletableFuture redesign that reduces blocking in message replication.
CompletableFutureConcurrencyDistributed Messaging
0 likes · 10 min read

This article explains core operating system concepts—including its main functions, the distinction between user and kernel modes, process and thread management, and semaphore-based synchronization—providing clear definitions, code examples, and practical usage scenarios for developers.
SemaphoreThreadkernel
0 likes · 8 min read

This article details how a large‑scale lottery service was architected and tuned for extreme traffic spikes by applying server‑side rate limiting, application‑level throttling, behavior‑based filtering, caching strategies, database optimizations, and hardware upgrades, resulting in a ten‑fold performance improvement.
Semaphorebackend architecturedatabase tuning
0 likes · 12 min read

This tutorial explains how Docker can streamline building, testing, and deploying Go web applications, introduces the use of Semaphore for continuous deployment, and walks through creating development and production Dockerfiles, configuring CI/CD pipelines, and managing updates on the server.
DockerGoSemaphore
0 likes · 25 min read

This article explains the classic producer‑consumer synchronization challenge, describes its importance in concurrent programming, and provides two complete C implementations—one using mutexes and condition variables and another using semaphores—along with detailed code and sample output.
C++ConcurrencyMutex
0 likes · 9 min read

This tutorial shows how to containerize a Go web application with Docker, use Beego for routing, set up development and production Dockerfiles, run automated tests, and integrate Semaphore for continuous integration and deployment, enabling consistent environments and streamlined workflows.
CI/CDContainerizationDocker
0 likes · 24 min read

This article narrates a thread’s life inside an operating system, using vivid analogies and stories to explain processes, thread states, mutexes, semaphores, locking strategies, deadlock scenarios, and best practices for safe concurrent programming in Java.
MutexSemaphoreThread
0 likes · 18 min read

This article explains how to manage the throughput of Java 21 virtual threads by using Executors to create them and applying java.util.concurrent.Semaphore to limit concurrent execution, ensuring efficient and safe concurrency without pooling virtual threads.
ConcurrencyJavaSemaphore
0 likes · 4 min read

The article categorizes Linux kernel synchronization primitives by their target—critical sections, CPUs, memory, or cache—detailing atomic variables, spinlocks, semaphores, mutexes, read‑write locks, preemption, RCU, and memory barriers, explaining their mechanisms, trade‑offs, and typical kernel usage examples.
LinuxLocksSemaphore
0 likes · 15 min read

The article systematically explains Linux kernel synchronization primitives—from basic atomic operations through queued spinlocks, counting semaphores, and sleeping mutexes to read‑write semaphores and per‑CPU variants—detailing their underlying data structures, memory‑barrier semantics, and the fast‑path and slow‑path acquisition and release APIs.
Linux kernelMutexSemaphore
0 likes · 13 min read

This article explains how to restrict a third‑party API to five requests per second in Go by combining a rate limiter to pace job starts and a semaphore to cap concurrent executions, complete with a full, runnable code example and detailed implementation notes.
BackendGoQPS
0 likes · 7 min read

This article explains essential techniques for managing concurrent access and race conditions in PHP, covering mutex locks, semaphores, atomic operations, queue-based processing, database access optimization, and transaction management to improve system reliability and performance.
ConcurrencyMutexPHP
0 likes · 5 min read

This article explains how to create three Java threads that print the characters A, B, and C in order, first without synchronization, then using Semaphore for ordered output, and finally extending the solution to repeat the ABC sequence twenty times.
ConcurrencyJavaMultithreading
0 likes · 7 min read

This article shares a detailed account of a Tencent testing engineer interview, covering self‑introduction, Go knowledge, Redis performance, distributed lock implementation, semaphore mechanics, RPC vs HTTP, concurrency usage, Git security practices, Linux commands, and a few brain‑teaser and algorithm questions.
BackendGoInterview
0 likes · 13 min read

This article explains how Redisson extends Redis to provide a rich set of distributed Java objects and services, walks through integrating Redisson into a Spring Boot project, demonstrates various lock types (reentrant, read‑write, semaphore, latch) with code examples, and details the internal watchdog mechanism that guarantees atomic lock acquisition and automatic renewal.
Distributed LockJavaRedis
0 likes · 19 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

The article explains how Redis cache expiration can cause a cache avalanche, describes typical scenarios, and presents mitigation techniques such as semaphore-based rate limiting and fault tolerance, accompanied by a Java service example demonstrating lock, semaphore, and cache handling.
BackendJavaRedis
0 likes · 7 min read

This article explains Java's AbstractQueuedSynchronizer (AQS) framework, covering its MESA monitor model, entry and condition wait queues, exclusive and shared lock acquisition and release, and how core concurrency utilities like ReentrantLock, ReadWriteLock, CountDownLatch, Semaphore, ThreadPoolExecutor, and CyclicBarrier are built upon it.
AQSConcurrencyCondition
0 likes · 30 min read

This article explains a Java technique for limiting asynchronous task execution to a fixed queries‑per‑second rate using a Semaphore‑based thread pool, a LinkedBlockingQueue, and a daemon thread that manages task dispatch, shutdown, and idle waiting.
ConcurrencyJavaQPS
0 likes · 6 min read

The article explains how Redis cache expiration can cause a request avalanche that overloads databases, and presents mitigation techniques such as semaphore rate limiting, per‑key locking, fault‑tolerant cache rebuilding, and example Java code using Spring and Redis.
CacheJavaRedis
0 likes · 8 min read

This article explains how to use Java's java.util.concurrent.Semaphore together with a fixed-size thread pool to enforce a precise QPS limit for asynchronous tasks, providing API details, implementation steps, and a complete test example.
BackendConcurrencyJava
0 likes · 6 min read

This article explains how miscalculating Hystrix semaphore quotas, combined with a JDK GCLocker‑initiated GC bug, can cause unexpected request rejections, and provides a proper method for computing concurrency limits and alternative buffering strategies such as Java semaphores and thread pools.
BackendGCHystrix
0 likes · 9 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 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 provides a comprehensive guide to Python threading, covering core concepts such as thread creation, synchronization primitives like locks, RLocks, conditions, semaphores, events, local storage, and timers, complete with practical code examples and explanations of their usage and pitfalls.
LockPythonSemaphore
0 likes · 12 min read

This article introduces Java's Semaphore as a thread‑synchronization tool, explains its flow‑control use cases such as database connections and parking lots, provides a complete parking‑lot simulation code sample, and analyzes the underlying AQS‑based implementation including fairness, acquire/release mechanics, and auxiliary methods.
AQSConcurrencyJava
0 likes · 13 min read


JavaEdgeApr 29, 2021 · Interview Experience
This article explains the semaphore model, its three core operations (init, down, up), how they manage counters and waiting queues, and demonstrates proper usage in Java to achieve mutual exclusion and resource limiting, complete with code examples and visual diagrams.
InterviewJavaSemaphore
0 likes · 6 min read

This article explains the purpose and usage of Java's Semaphore class, demonstrates how it can be applied for rate limiting with real‑world analogies, provides a complete parking‑lot example with source code, and discusses fairness modes and additional Semaphore APIs.
BackendConcurrencyJava
0 likes · 12 min read

This session reviews PThread fundamentals and advanced techniques in C, covering thread creation, termination, attributes, mutexes, reader‑writer locks, condition variables, semaphores, barrier synchronization, and thread‑specific data, with code examples and a concluding homework assignment.
MultithreadingMutexSemaphore
0 likes · 11 min read

This article presents various Java solutions for common interview multithreading problems that require sequential printing, demonstrating implementations using Lock, wait/notify, Condition, Semaphore, and LockSupport, along with detailed code examples and explanations of thread communication mechanisms.
ConcurrencyJavaLock
0 likes · 15 min read

This article explains how to improve a fixed QPS mock interface in Java by adding a compensation thread that adjusts request timing using a thread‑safe counter, reducing error beyond the original 5% tolerance.
ConcurrencyJavaQPS
0 likes · 5 min read

This article explains the core synchronization mechanisms used in modern Linux kernels—including atomic operations, spinlocks, semaphores, and mutexes—detailing their definitions, underlying implementations, API usage, performance characteristics, and appropriate usage scenarios across different execution contexts such as process, interrupt, and soft‑interrupt contexts.
Linux kernelMutexSemaphore
0 likes · 12 min read

This article explains the shared‑mode acquisition in Java's AbstractQueuedSynchronizer, walks through the core template methods, compares them with exclusive mode, and demonstrates a classic application by dissecting the Semaphore source code and its usage patterns.
AQSConcurrencyJava
0 likes · 14 min read

This article explains how to overcome the difficulty of isolating external service performance during load testing by creating a fixed‑QPS mock endpoint using Java's Semaphore and a custom Moco ResponseHandler, includes code samples, accuracy observations, and practical guidelines.
JavaMoCoMock API
0 likes · 5 min read

This article explains Python's threading module, demonstrating how to import it, create and manage single and multiple threads, use thread locks (Lock and RLock), condition variables, semaphores, events, thread‑local storage, and timers, providing complete code examples for each concept.
ConcurrencyEventLock
0 likes · 12 min read

This article uses a factory analogy to demystify operating‑system concepts such as processes, threads, mutual‑exclusion locks, and semaphores, illustrating how CPUs, workspaces, workers, and access controls interact to enable concurrent execution while preventing conflicts.
ConcurrencyMutexSemaphore
0 likes · 5 min read

This article explores eight Java concurrency techniques—including join, main‑thread join, wait/notify, thread pools, Condition, CountDownLatch, CyclicBarrier, and Semaphore—to achieve sequential thread execution, complete with code examples and sample outputs for each method.
ConcurrencyJavaSemaphore
0 likes · 22 min read

This article explains why multithreading is needed, outlines the challenges of concurrent access, and provides a detailed overview of four Java thread lock mechanisms—synchronized, ReentrantLock, Semaphore, and AtomicInteger—along with their characteristics, usage patterns, and performance considerations.
ConcurrencyJavaSemaphore
0 likes · 9 min read

The article explains how MySQL's InnoDB engine triggers a semaphore crash after a thread waits over 600 seconds, details the lock locations in dict0dict.c and btr0sea.c, examines the role of Adaptive Hash Index and buffer pool pressure, and introduces a small utility (mysqldba) to help DBAs diagnose and resolve such issues.
InnoDBLockMySQL
0 likes · 9 min read

The article explains why InnoDB semaphore waits exceeding 600 seconds trigger server crashes, details the lock structures and functions involved, shows how buffer pool pressure and metadata statistics cause contention, and introduces a small DBA utility that parses MySQL error logs to reveal the relationships between threads, locks, and transactions.
DBAInnoDBMySQL
0 likes · 8 min read

This article explains the internal workings of Java's Semaphore, detailing its AQS-based architecture, fair and non‑fair synchronization strategies, core methods such as acquire, release, and their implementations, and provides a practical example demonstrating semaphore usage for thread coordination.
AQSConcurrencyJava
0 likes · 12 min read

This article explains the concept and internal design of Java's Semaphore, shows how to create fair or non‑fair instances, details the acquire and release operations, compares fairness strategies, and provides a complete parking‑lot example with runnable code and output.
AQSConcurrencyFair vs Nonfair
0 likes · 8 min read


ITPUBAug 18, 2017 · Fundamentals
The article explains what deadlocks are, compares spinlocks and semaphores, describes typical deadlock scenarios in the Linux kernel, and details the built‑in detection mechanisms such as hung‑task (D‑state) and soft‑lockup (R‑state) along with the NMI watchdog for long interrupt disabling.
LinuxSemaphoredeadlock
0 likes · 14 min read


ITPUBAug 17, 2016 · Fundamentals
This article explains how deadlocks arise in Linux kernels, compares spinlocks and semaphores, and details the kernel's built‑in D‑state, R‑state, and long‑interrupt‑disable detection mechanisms such as hung‑task, soft‑lockup, and NMI watchdog, including key code snippets.
LinuxSemaphoredeadlock
0 likes · 14 min read

This article explains the concept of rate limiting to protect system stability, outlines when to apply it during high‑traffic events, and provides a concise Java implementation using Semaphore, including code snippets for acquiring, processing, and releasing permits.
BackendConcurrencySemaphore
0 likes · 3 min read
