Understanding C++11 std::atomic for Thread-Safe Programming

The previous section introduced the simplest atomic type in C++11, std::atomic_flag, but it's too limited with only test_and_set and clear APIs. It doesn't meet other requirements like store, load, exchange, and compare_exchange. This article will explore the more comprehensive std::atomic class. Basic std::atomic Types Explained Introduction t ...

Posted on Fri, 30 Oct 2026 16:12:19 +0000 by tdnxxx444

Singleton Pattern: Five Implementation Approaches

Overview The Singleton pattern ensures a class has exact one instance and provides a global point of access to it. The core challenge is: how to bypass traditional constructors and guarantee a single instance? Clients calling a class should not concern themselves with instance count restrictions—this responsibility falls on the class designer, ...

Posted on Tue, 27 Oct 2026 16:30:40 +0000 by ntohky14

Singleton Pattern Implementation Strategies in Java

The singleton pattern is a creational design pattern that ensures a class has only one instance and provides a global point of access to it. While conceptually simple, its correct implementation—especially under concurrent conditions—requires careful attention to initialization timing, thread safety, memory visibility, and JVM-level optimizatio ...

Posted on Wed, 30 Sep 2026 16:17:02 +0000 by faifas

Singleton Pattern Implementation Strategies and Security Considerations

The Singleton pattern represents one of the most fundamental design patterns in software engineering, providing an efficient mechanism for ensuring that exact one instance of a class exists throughout the application lifecycle. Core Principles of Singleton Implementation There are two primary approaches to implementing the Singleton pattern: E ...

Posted on Thu, 17 Sep 2026 16:19:48 +0000 by flashpipe

Understanding Synchronized in Java Concurrency

Overview of Synchronized The synchronized keyword in Java is a mechanism for coordinating access to shared resources among multiple threads. It ensures that only one thread can execute a synchronized block or method at any given time, thus preventing race conditions and ensuring thread safety. Synchronized Code Blocks and Methods A synchronized ...

Posted on Sun, 13 Sep 2026 16:30:29 +0000 by b

Implementing the Observer Pattern in Java for Event-Driven Systems

The Observer pattern is a foundational behavioral design pattern that enables loose coupling between components by defining a one-to-many dependency between objects: when one object (the subject) changes state, all its dependents (observers) are automatically notified and updated. This pattern underpins many event-handling systems in Java, incl ...

Posted on Mon, 24 Aug 2026 16:48:56 +0000 by XPertMailer

Java Thread-Safe Collections: ConcurrentHashMap vs HashMap in Concurrent Environments

Overview of Java Thread-Safe Classes Class Type Characteristics Description Legacy Thread-Safe Classes Uses synchronized for thread safety Deprecated classes like Stack, Vector, Hashtable Collections-Decorated Classes Wrapper classes using synchronized Thread-safe versions of standard collections JUC Classes Uses CAS and multiple loc ...

Posted on Tue, 18 Aug 2026 16:58:00 +0000 by Ali25m

Thread-Safe Logging Library Using Win32 APIs in C++

Here is a C++ logging library implemented with Win32 APIs that ensures thread safety. It consists of just two files, making it simple to integrate and use. Header File The header file includes several functions for logging operations. While there are many interfaces defined, only a few are common used: WriteProgramLogNoMask: Outputs log entrie ...

Posted on Thu, 16 Jul 2026 16:47:01 +0000 by Ehailey

Concurrency Control in Java: Comparing synchronized and volatile

synchronized vs volatile In Java concurrency, synchronized and volatile are two fundamental mechanisms for ensuring thread safety, but they serve different purposes. The synchronized keyword establishes a mutual exclusion lock. When a method or code block is decorated with synchronized, only one thread can execute that critical section at any g ...

Posted on Wed, 08 Jul 2026 17:16:06 +0000 by Averice

Refactoring a Cross-Platform Serial Port Library for Thread-Safe Data Handling

Overview The CustomSerialPort library (available at flyfire.CustomSerialPort) builds upon the SerialPortStream library to provide protocol-agnostic complete frame reception with cross-platform support. While the library offers general-purpose serial port functionality, the implementation contains several architectural issues that warrant attent ...

Posted on Sun, 05 Jul 2026 16:02:25 +0000 by moffo