This article explains the fundamentals of the compare‑and‑swap (CAS) atomic primitive, how CPUs guarantee its atomicity through bus and cache locking, illustrates a Java spin‑lock implementation using CAS, and discusses typical issues such as single‑variable limitation, long spin times, and the ABA problem with mitigation strategies.
This article explores Java's sun.misc.Unsafe class, detailing its construction, key capabilities such as low‑level memory management, object instantiation, class loading, CAS operations, and thread scheduling, while highlighting safety concerns and appropriate usage scenarios.
This article explains the design principles, lock mechanisms, CAS operations, and resizing strategies of Java's ConcurrentHashMap, illustrating how it achieves thread safety and high concurrency compared to HashMap and Hashtable in modern Java applications.
This article provides a detailed overview of authentication mechanisms, covering UI login methods such as Basic, LDAP, OAuth, Kerberos, and SSO, API call verification techniques like HMAC and JWT, and practical design guidelines for implementing SSO with CAS in micro‑service architectures.
AtomicInteger provides a thread‑safe, lock‑free counter in Java by employing optimistic locking and CAS operations, offering higher efficiency than synchronized blocks; the article explains its motivation, usage examples, underlying Unsafe mechanisms, volatile semantics, and key methods such as incrementAndGet and compareAndSet.
This article explores the challenges of cross‑domain login state sharing, compares JWT, session‑cookie, and SSO solutions such as CAS and OAuth, details their structures, security considerations, and provides a step‑by‑step guide to building a simple SSO demo with code snippets and diagrams.
This article explains the full spectrum of Java concurrency locks—including pessimistic, optimistic, exclusive, shared, fair, unfair, segment, reentrant, and spin locks—detailing their principles, typical use cases, implementation details, and code examples to help you ace interview questions.
This article dives deep into Java's ConcurrentHashMap, explaining how it uses CAS, volatile fields, lock‑striping and cooperative resizing to provide thread‑safe get, put and size operations while maximizing concurrency and performance.
This article provides an in‑depth overview of authentication, covering both UI login and API call methods such as Basic, LDAP, OAuth, Kerberos, SSO, HMAC, and JWT, and explains how to design secure, cross‑domain authentication components within micro‑service architectures.
The article compares Java's pessimistic locking mechanisms such as synchronized blocks and ReentrantLock with optimistic approaches like version checks, CAS‑based AtomicInteger and custom spin locks, illustrating each method through counter examples and discussing their performance trade‑offs and limitations.
This article provides a comprehensive guide to authentication, covering basic username/password login, LDAP, OAuth 2.0, Kerberos, SSO with CAS, as well as API authentication methods like HMAC and JWT, and offers design recommendations for both UI and API security in micro‑service architectures.
The article explains how the volatile keyword ensures prompt visibility of variables across threads, illustrates its effect with a concurrent increment example, highlights that visibility does not guarantee atomicity, and introduces CAS as a solution for correct concurrent updates.
This article explains why LongAdder was introduced to overcome AtomicLong's CAS contention bottleneck, explores the design of Striped64 and its cells, and walks through key source code snippets of LongAdder, DoubleAdder, and the longAccumulate method, highlighting concurrency mechanisms and performance considerations.
GrowingIO’s server-side solution integrates three distinct authentication protocols—OAuth2, LDAP, and CAS—into a unified SSO flow, detailing each protocol’s process, the overall architecture, role of the IAM and Gateway components, and providing configuration and code examples for implementation.
This article explains a complete CAS-based single sign‑on solution, covering traditional session mechanisms, the CAS architecture, implementation of single sign‑on, session renewal, single logout, and practical extensions for multi‑system integration to ensure secure and seamless user experiences across enterprise applications.
This article provides an in-depth exploration of Java concurrency and synchronization mechanisms, detailing the evolution of the Java Memory Model, explaining core concepts like volatile, CAS, synchronized, and park/unpark, and illustrating their practical applications through code examples and JVM optimization insights.
This article explains how Java 8’s ConcurrentHashMap improves concurrency by replacing segment locks with fine‑grained CAS operations, introduces ForwardingNode for lock‑free resizing, and details the internal algorithms for initialization, put, dynamic expansion, and size counting, complete with code examples.
This article explains Java thread safety by defining it, breaking down atomicity, visibility, and ordering, illustrating core concepts with AtomicInteger and AtomicStampedReference examples, and detailing the underlying CAS mechanisms, JMM rules, and the ABA problem.
This article explains the limitations of volatile for compound updates, demonstrates non‑thread‑safe bank‑account examples, introduces synchronized locking, and then shows how AtomicReference with CAS operations provides a lock‑free, thread‑safe solution, including a deep dive into its internal implementation and related memory‑barrier concepts.
This article explains the fundamentals of Single Sign-On (SSO) and the CAS framework, outlines suitable use cases, compares three implementation approaches, details key CAS components and ticket types, and walks through a step‑by‑step cross‑domain SSO deployment process.
This article explains the fundamentals of lock‑free queues, covering CAS and other atomic operations, detailed enqueue and dequeue implementations, the ABA problem and its solutions, as well as array‑based lock‑free queue designs, providing code examples and practical insights.
This article explains the internal design of Java's ConcurrentHashMap, covering its evolution from JDK7 to JDK8, the segment‑based locking mechanism, lock‑free reads, CAS operations, table resizing, treeification, and the key classes and methods that enable efficient concurrent access while maintaining thread safety.
This article explains how Java's AtomicInteger and related atomic classes provide lock‑free thread‑safe operations to replace non‑atomic constructs like i++, detailing their inheritance, underlying Unsafe mechanisms, CAS implementation, memory barriers, optimistic locking, the ABA problem, and practical code examples for increment, decrement, and custom CAS‑based locks.
This article provides an in‑depth overview of Java multithreading, covering fundamental concepts such as processes, threads, parallelism vs concurrency, thread creation methods, lifecycle states, synchronization mechanisms, memory model nuances, lock implementations, common pitfalls like deadlocks, and practical usage of thread pools with best‑practice recommendations.
This article explains the ABA issue that can occur in Java's compare‑and‑swap (CAS) operations, illustrates it with a building‑block analogy and concrete code examples, and shows how versioned atomic references such as AtomicStampedReference can reliably prevent the problem.
This article explains Java's Compare-And-Swap (CAS) mechanism, illustrates its usage with AtomicInteger code examples, walks through step‑by‑step debugging of CAS operations, and discusses its advantages, limitations such as the ABA problem and spin‑wait overhead.
This article explains Java's memory model, the limitations of synchronized and volatile, introduces the java.util.concurrent.atomic package, details the CAS algorithm, the role of the Unsafe class, common pitfalls like the ABA problem, and presents code examples and solutions such as AtomicStampedReference.
This article explains the various types of locks provided by Java, compares optimistic and pessimistic locking, introduces spin locks and adaptive spin locks, details lock states such as biased, lightweight, and heavyweight, and examines fair versus non‑fair, reentrant versus non‑reentrant, and exclusive versus shared locks with source code references.
This article explains the ABA issue inherent in Java's CAS operations, demonstrates it with AtomicInteger examples, and shows how AtomicStampedReference (and AtomicMarkableReference) use version stamps to prevent erroneous multiple updates in multithreaded environments.
This article explains how ConcurrentHashMap ensures thread safety in Java, comparing the lock‑segmentation design of JDK 7 with the CAS‑based, bucket‑level synchronization of JDK 8, and includes key source code excerpts illustrating the insertion process.
This article explains Java's Unsafe class, its low‑level memory operations, how Compare‑and‑Swap (CAS) is implemented via Unsafe, and how AtomicInteger leverages CAS for lock‑free thread safety while also covering the ABA problem and its mitigation.
This article explains why Java uses locks to prevent dirty reads and data inconsistency, compares volatile and synchronized mechanisms, details monitor-based lock implementation, lock optimizations like biased and lightweight locks, introduces CAS and AbstractQueuedSynchronizer, and illustrates these concepts with code examples and diagrams.
This article explains the Compare‑and‑Swap (CAS) mechanism, its hardware‑level implementation via Java’s Unsafe class, provides sample code for basic CAS, atomic adders, custom atomic types, analyzes the ABA problem, and presents solutions such as versioned stamps and AtomicStampedReference.
This article explains the Compare‑And‑Swap (CAS) primitive, its three operands, how Java's Unsafe class implements CAS methods, the internal workings of AtomicInteger, common pitfalls like spinning, single‑variable limits and the ABA problem, and the enhancements introduced in Java 8.
This article explains the fundamentals of Single Sign‑On (SSO), covering same‑origin policy, cookies and sessions, browser login flows, challenges of multi‑system authentication across subdomains and different domains, front‑end cross‑origin techniques, and an overview of the CAS protocol.
This article explains the background, architecture, and step‑by‑step authentication flow of Single Sign‑On systems, covering the classic CAS framework, Java implementation details, and Taobao's extended SSO design with code examples.
This article explains why locks are needed in Java, compares volatile and synchronized, describes monitor‑based synchronization, lock optimizations such as biased and lightweight locks, introduces CAS and the AbstractQueuedSynchronizer framework, and provides practical code examples and usage scenarios.
This article explains how java.util.concurrent.atomic.LongAdder provides a more efficient counting mechanism than AtomicLong under high contention, discusses its trade‑offs in space and precision, presents JMH benchmark results, and walks through the internal implementation details such as cells, CAS loops, and hash‑based distribution.
This article explains why thread safety concerns memory rather than threads, compares stack‑local and heap‑shared data, introduces ThreadLocal for per‑thread isolation, and covers mutual‑exclusion locks, optimistic CAS, and their appropriate use cases in concurrent programming.
This article introduces Java multithreading by explaining the relationship between processes and threads, the benefits of concurrency, common pitfalls like race conditions, and how to safely manage shared variables using ThreadPoolExecutor, AtomicInteger, volatile, and CAS operations.
The article explains why thread safety concerns memory rather than threads, describes how local stack variables, ThreadLocal, locks, and CAS provide isolation and consistency in Java concurrency, and compares optimistic and pessimistic locking strategies with illustrative code examples.
This article explains the concepts of concurrency control, detailing pessimistic and optimistic locking mechanisms, their implementation in MySQL, practical SQL examples, advantages, drawbacks such as deadlocks and ABA problems, and guidance on selecting the appropriate lock strategy for high‑concurrency applications.
This article reviews the weaknesses of cookie‑based single sign‑on, explains the unified authentication center approach, and details the complete CAS (Central Authentication Server) login flow—including first, second, and cross‑domain accesses—illustrated with diagrams.
The article explains Java’s various lock mechanisms—including optimistic vs. pessimistic, spin and adaptive spin, no‑lock through heavyweight states, fair vs. unfair, reentrant vs. non‑reentrant, and exclusive vs. shared locks—using JDK 8 source code and practical examples to guide developers in choosing the appropriate lock for different concurrency scenarios.
This article explains how to fix red‑packet over‑issuance bugs using optimistic locking with CAS, introduces version fields to prevent ABA problems, shows DAO, service and controller code updates, and demonstrates time‑based and count‑based retry strategies to improve success rates under high concurrency.
The article explains the concepts of pessimistic and optimistic locking, details how CAS (Compare‑And‑Swap) implements optimistic locks in Java, discusses their advantages, drawbacks such as the ABA problem and high spin costs, and compares CAS usage with synchronized blocks in concurrent programming.
This article explains the fundamentals of CAS-based Single Sign‑On, detailing the roles of CAS Server and Client, the ticket‑granting process, login and logout flows, session handling, and how global and local sessions interact to provide seamless authentication across multiple web applications.
CAS (Central Authentication Service) is an open‑source, enterprise‑grade single sign‑on solution that centralizes user authentication across trusted systems, offering reduced login time, improved security, and streamlined user management, with a clear protocol flow involving service tickets, redirects, and encrypted cookies.
This article explains the lock‑free design of Java's ConcurrentLinkedQueue, detailing its core invariants, the internal Node structure, and step‑by‑step analyses of the offer and poll methods with code snippets and visual illustrations to demystify its CAS‑based concurrency mechanisms.
This article explains why locks are needed in concurrent programming, explores the fundamentals of volatile and synchronized, details monitor mechanisms, lock optimizations like biased and lightweight locks, compares CAS and AQS, and illustrates Java lock implementations with diagrams and code examples.
This article explains why locks are needed in Java, describes the fundamentals of volatile and synchronized, details monitor-based synchronization, explores lock optimizations such as biased and lightweight locks, and covers CAS and the AbstractQueuedSynchronizer framework for building concurrent structures.
This article explains why locks are essential for preventing dirty reads and data inconsistency, explores the principles behind volatile, synchronized, monitor, CAS, and AQS, and illustrates Java’s lock implementations, optimizations, and practical usage examples such as ConcurrentHashMap.
This article explains the Central Authentication Service (CAS) as an open‑source enterprise SSO solution, detailing its features, authentication flow, architecture, proxy mode, and security mechanisms that rely on SSL and secure tickets.
This article examines three Java concurrency implementations—CopyOnWriteArrayList, ConcurrentHashMap, and LinkedBlockingQueue—explaining their underlying principles, code structures, and how they achieve thread‑safe read/write operations using techniques such as copy‑on‑write, CAS, and separate locks.
This article provides a high‑level summary of Java concurrency, covering thread creation methods, thread models, thread pools, Future and CompletableFuture, the Fork/Join framework, volatile, CAS, AQS, synchronized locks, and concurrent queue implementations, with code examples and reference links for deeper study.
This article explains how lock-free techniques such as Compare-And-Swap (CAS) and Java's atomic classes—including AtomicBoolean, AtomicInteger, AtomicReference, and their array and field updaters—provide optimistic concurrency control, reduce context switches, and improve performance compared to traditional locking mechanisms.
On May 3, China announced the creation of the world’s first optical quantum computer that outperforms early classical machines, highlighting breakthroughs by the University of Science and Technology of China, Alibaba‑CAS quantum lab, Zhejiang University and others, and outlining rapid advances in photonic and superconducting qubit technologies.
This article explains why concurrent read‑write operations on a shared balance can cause inconsistencies, illustrates the problem with a purchase‑balance example, and shows how a Compare‑And‑Set (CAS) update clause guarantees atomicity and preserves data integrity.
The article explains why enterprises need a unified Single Sign-On (SSO) system, detailing its benefits for user convenience, administrator workload reduction, security improvements, and integration standards, while comparing cookie‑ and session‑based implementations and illustrating the CAS open‑source solution.
This article explains how to generate red packets, calculate random amounts, and handle user grabbing and opening actions while ensuring high‑concurrency safety using atomic CAS operations in a cache to prevent oversubscription.
The article analyzes the use of a master/slave architecture for distributed caching, explains why two clusters, CAS, and proxy are employed, discusses consistency and availability challenges, and evaluates possible mitigation strategies for cache failures.