Tagged articles

Thread Safety

233 articles · Page 1 of 3
Java Tech Workshop
Java Tech Workshop
Jun 23, 2026 · Backend Development

Request vs Session Scope: Usage Scenarios and Thread‑Safety Pitfalls in Java Web

Understanding the lifecycle, scope, and thread characteristics of HttpServletRequest and HttpSession reveals common misuse that leads to data corruption, login state errors, and lost cart data; the article explains core differences, proper use cases, real‑world bug examples, and practical solutions such as read‑only policies, synchronization, thread‑safe collections, and Redis‑based session storage.

Request ScopeSession ScopeSpring Boot
0 likes · 14 min read
Request vs Session Scope: Usage Scenarios and Thread‑Safety Pitfalls in Java Web
Deepin Linux
Deepin Linux
Jun 23, 2026 · Fundamentals

How Type Traits Rescue a Broken C++ Object Pool and Enable Type‑Adaptive Pooling

The author recounts how a naïve generic C++ object pool caused data residue, construction failures, and incompatibility with primitive types, then demonstrates a refactored, thread‑safe pool that leverages compile‑time Type Traits, std::enable_if, and constexpr if to apply distinct creation, reset, and destruction logic for trivial, Clear‑able, and non‑trivial types, eliminating the earlier bugs.

C++Template MetaprogrammingThread Safety
0 likes · 11 min read
How Type Traits Rescue a Broken C++ Object Pool and Enable Type‑Adaptive Pooling
Deepin Linux
Deepin Linux
Jun 22, 2026 · Backend Development

Memory Pool vs Object Pool: When to Choose and How to Build One from Scratch

The article explains why high‑concurrency programs suffer from memory fragmentation and system‑call overhead, compares memory pools and object pools, outlines their distinct use‑cases, provides step‑by‑step C and C++ implementations, and highlights optimization tips and common pitfalls.

C++Memory poolThread Safety
0 likes · 20 min read
Memory Pool vs Object Pool: When to Choose and How to Build One from Scratch
Coder Life Journal
Coder Life Journal
Jun 17, 2026 · Fundamentals

Why HashMap Is Not Thread‑Safe: A Deep Dive into the Source Code

The article explains how HashMap can enter an infinite loop, lose data, or corrupt entries when accessed concurrently, illustrates the root causes with JDK 1.7 and 1.8 source code, compares alternative thread‑safe maps, and shows how to answer this classic interview question.

ConcurrentHashMapData RaceHashMap
0 likes · 7 min read
Why HashMap Is Not Thread‑Safe: A Deep Dive into the Source Code
liandk
liandk
Jun 13, 2026 · Fundamentals

Singleton Pattern: Simple Explanation, Java Code Samples, and Real‑World Use Cases

The article explains the Singleton pattern—ensuring a class has only one global instance—to save resources and avoid conflicts, illustrates two Java implementations (eager and lazy), and lists typical scenarios such as logging utilities, connection pools, global configuration, and exclusive resources.

Design PatternEager InitializationLazy Initialization
0 likes · 4 min read
Singleton Pattern: Simple Explanation, Java Code Samples, and Real‑World Use Cases
Deepin Linux
Deepin Linux
Jun 12, 2026 · Interview Experience

Avoid the Top 4 Static Keyword Traps in C/C++ Interviews and Secure Your Offer

The article explains the four most frequently tested static keyword pitfalls in C/C++ interviews—local variable initialization, thread‑unsafe functions, file‑level global scope, and class member sharing—detailing their underlying lifetime and scope rules, common misconceptions, and a concise answer template to prevent losing an offer.

C++InterviewScope
0 likes · 11 min read
Avoid the Top 4 Static Keyword Traps in C/C++ Interviews and Secure Your Offer
samdeepthink
samdeepthink
May 22, 2026 · Backend Development

How to Answer Bean Thread‑Safety Questions from an Architecture‑Responsibility Perspective

The article breaks down Bean thread‑safety into container‑level creation safety and business‑level usage safety, explains Spring's four concurrency strategies, details the implementation of Singleton, Prototype, Request and Session scopes, compares them with other DI frameworks, and argues why Spring's division of responsibilities is appropriate.

BeanScopeSpring
0 likes · 14 min read
How to Answer Bean Thread‑Safety Questions from an Architecture‑Responsibility Perspective
Java Tech Workshop
Java Tech Workshop
May 8, 2026 · Fundamentals

6 Common Misconceptions About Java’s static Keyword

This article debunks six frequent misunderstandings of Java’s static keyword, covering its class-level nature, the impossibility of overriding static methods, the prohibition of this/super in static contexts, the one‑time execution of static blocks, the lack of inherent thread safety for static variables, and why static fields should not be initialized in constructors or instance blocks.

InitializationMemory ModelThread Safety
0 likes · 10 min read
6 Common Misconceptions About Java’s static Keyword
IT Services Circle
IT Services Circle
May 2, 2026 · Fundamentals

7 Recurring Mistakes I See in Every PR After Reviewing Over 1,000

After reviewing more than a thousand pull requests, the author identifies seven recurring problems—unreadable code, hidden error handling, thread‑safety oversights, N+1 database queries, hard‑coded configuration, ignoring failure paths, and overly large PRs—and explains why they matter and how to avoid them.

Code ReviewSoftware EngineeringThread Safety
0 likes · 13 min read
7 Recurring Mistakes I See in Every PR After Reviewing Over 1,000
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Apr 20, 2026 · Backend Development

Avoid Hidden Thread‑Safety Bugs in Spring Boot 3: 6 Common Pitfalls and Fixes

This article examines six typical concurrency mistakes in Spring Boot 3—misusing volatile, unsafe ConcurrentHashMap patterns, exposing mutable collections, removing synchronized, abusing parallel streams, and invisible shutdown flags—showing why they occur and providing concrete, thread‑safe code replacements.

ConcurrentHashMapSpring BootThread Safety
0 likes · 9 min read
Avoid Hidden Thread‑Safety Bugs in Spring Boot 3: 6 Common Pitfalls and Fixes
Go Development Architecture Practice
Go Development Architecture Practice
Apr 13, 2026 · Backend Development

Why FastCache Is the Go Developer’s Secret Weapon for Ultra‑Fast, Zero‑GC Local Caching

FastCache, an open‑source Go in‑memory cache from the VictoriaMetrics team, delivers extreme speed, zero garbage‑collector pressure, and built‑in thread safety through a shard‑bucket design, while offering a five‑method API that lets developers cache massive key‑value data with minimal configuration, making it ideal for high‑concurrency services and low‑latency workloads.

FastCacheGoThread Safety
0 likes · 7 min read
Why FastCache Is the Go Developer’s Secret Weapon for Ultra‑Fast, Zero‑GC Local Caching
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Dec 22, 2025 · Fundamentals

Why Is StringBuilder Faster Than StringBuffer? Understanding Java’s Mutable vs Immutable Strings

This article explains the fundamental differences between Java's String, StringBuilder, and StringBuffer—covering immutability, thread‑safety, internal caching mechanisms, and performance characteristics—while providing concrete code examples that illustrate how each class behaves in single‑threaded and multi‑threaded scenarios.

StringBufferStringBuilderThread Safety
0 likes · 6 min read
Why Is StringBuilder Faster Than StringBuffer? Understanding Java’s Mutable vs Immutable Strings
Liangxu Linux
Liangxu Linux
Oct 29, 2025 · Fundamentals

Why Use a Lightweight Ring Buffer? Deep Dive into LwRB for Embedded Systems

This article explains why circular buffers are essential for efficient data‑stream handling in embedded systems, introduces the open‑source LwRB library, details its memory‑safe and thread‑safe design using C11 atomics, provides core data structures and example code, and compares ring buffers with normal buffers and message queues.

DMAEmbedded CRing Buffer
0 likes · 14 min read
Why Use a Lightweight Ring Buffer? Deep Dive into LwRB for Embedded Systems
Liangxu Linux
Liangxu Linux
Oct 23, 2025 · Fundamentals

Why Use a Lightweight Ring Buffer? Deep Dive into LwRB for Embedded Systems

This article explains the need for circular buffers in embedded development, introduces the lightweight LwRB library, details its memory‑safe and thread‑safe design using C11 atomics, walks through core data structures and two‑stage read/write algorithms, provides complete code examples, and compares ring buffers with normal buffers and message queues.

Ring BufferThread Safety
0 likes · 15 min read
Why Use a Lightweight Ring Buffer? Deep Dive into LwRB for Embedded Systems
Deepin Linux
Deepin Linux
Aug 17, 2025 · Fundamentals

Mastering C++ Singleton: 5 Implementations, Pitfalls & Performance Tips

This article explains why the singleton pattern is essential for global resources in C++, walks through five concrete implementations—from basic lazy and eager versions to thread‑safe double‑checked locking and C++11 static locals—analyzes their performance and resource trade‑offs, and provides a complete printer‑singleton case study with build and run instructions.

C++C++11Design Patterns
0 likes · 26 min read
Mastering C++ Singleton: 5 Implementations, Pitfalls & Performance Tips
Cognitive Technology Team
Cognitive Technology Team
Aug 17, 2025 · Backend Development

synchronized vs Lock in Java: When to Choose Each for Thread Safety

This article examines the core differences between Java's synchronized keyword and the Lock interface, covering their principles, performance, flexibility, visibility guarantees, reentrancy, interruption handling, and practical selection guidelines with code examples, tables, and real‑world scenarios to help developers choose the appropriate locking mechanism.

LockReentrantLockThread Safety
0 likes · 9 min read
synchronized vs Lock in Java: When to Choose Each for Thread Safety
Programmer Null's Self-Cultivation
Programmer Null's Self-Cultivation
Jul 13, 2025 · Backend Development

Unlocking the Secrets of Java’s ConcurrentHashMap: From JDK 7 to JDK 8

This article provides a comprehensive, step‑by‑step analysis of Java's ConcurrentHashMap, covering its evolution from JDK 7’s segment‑lock design to JDK 8’s bucket‑level CAS and synchronized approach, complete with macro diagrams, microscopic source‑code walkthroughs, hash calculations, resizing mechanisms, and practical usage tips.

ConcurrentHashMapHashMapJDK7
0 likes · 16 min read
Unlocking the Secrets of Java’s ConcurrentHashMap: From JDK 7 to JDK 8
Shepherd Advanced Notes
Shepherd Advanced Notes
Jul 2, 2025 · Fundamentals

45 Tips for Writing Clean, Beautiful Code

This article presents 45 practical coding tips—from naming conventions and formatting to exception handling, thread safety, and design patterns—illustrated with Java examples and real‑world scenarios, helping developers produce readable, maintainable, and robust code.

Design PatternsThread Safetybest practices
0 likes · 29 min read
45 Tips for Writing Clean, Beautiful Code
Java Tech Enthusiast
Java Tech Enthusiast
Jun 24, 2025 · Backend Development

Ace Your Java Backend Interview: From Self‑Intro to Redis Strategies and Design Patterns

This guide walks you through the realities of joining state‑owned enterprises, offers practical tips for Java backend interview preparation—including self‑introduction, project presentation, database choices, Redis eviction policies, common design patterns, singleton usage, thread‑safety concepts, and commands to terminate Java processes on Linux, macOS, and Windows.

Design PatternsLinux commandsRedis
0 likes · 16 min read
Ace Your Java Backend Interview: From Self‑Intro to Redis Strategies and Design Patterns
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
May 15, 2025 · Fundamentals

Mastering Thread‑Safe Classes in Java: 6 Proven Design Strategies

This article explains what makes a class thread‑safe in Java, illustrates common race‑condition pitfalls with sample code, and presents six practical design strategies—including stateless, immutable, synchronized, volatile, concurrent collections, thread‑confinement, and defensive copying—to help developers build robust, high‑performance concurrent applications.

Design PatternsImmutableThread Safety
0 likes · 11 min read
Mastering Thread‑Safe Classes in Java: 6 Proven Design Strategies
macrozheng
macrozheng
May 7, 2025 · Backend Development

Mastering Date and Time Handling in Java: Thread Safety, Time Zones, and Performance

This article explores common pitfalls in Java date handling, explains thread‑unsafe SimpleDateFormat issues, demonstrates safe alternatives with ThreadLocal, Java 8 Time API, and zone‑aware calculations, and provides performance‑optimized patterns for high‑throughput applications.

Spring BootThread SafetyTime Zone
0 likes · 10 min read
Mastering Date and Time Handling in Java: Thread Safety, Time Zones, and Performance
Su San Talks Tech
Su San Talks Tech
Apr 9, 2025 · Backend Development

Avoid These 7 Common Java Stream Mistakes for Cleaner, Faster Code

Learn the seven most frequent Java Stream pitfalls—from missing terminal operations and modifying source data to overusing intermediate steps and thread‑safety issues—and discover practical fixes that ensure your streams execute correctly, efficiently, and safely.

Stream APIThread Safetycommon mistakes
0 likes · 11 min read
Avoid These 7 Common Java Stream Mistakes for Cleaner, Faster Code
Liangxu Linux
Liangxu Linux
Mar 17, 2025 · Backend Development

Mastering log.c: A Lightweight C99 Logging Library for Embedded Systems

This guide introduces the log.c library, a compact C99‑based logger suitable for embedded platforms, covering its features, usage examples, level control, file output, callbacks, thread safety, and colorized output with code snippets and configuration details.

C99Thread Safetyembedded
0 likes · 6 min read
Mastering log.c: A Lightweight C99 Logging Library for Embedded Systems
Java Tech Enthusiast
Java Tech Enthusiast
Mar 4, 2025 · Backend Development

When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety

A ConcurrentHashMap is internally thread‑safe, so a volatile declaration is only required when its reference may be reassigned (or the field is final), while Spring singleton beans with mutable fields are not thread‑safe and should be made stateless, prototype‑scoped, or synchronized for composite operations.

ConcurrentHashMapSpringThread Safety
0 likes · 13 min read
When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Mar 4, 2025 · Backend Development

Hashtable vs HashMap: Thread Safety, Null Handling, and Performance Explained

An in‑depth comparison of Java’s Hashtable and HashMap covers their thread‑safety mechanisms, null‑key/value policies, inheritance hierarchy, default capacities, resizing strategies, and iterator behavior, highlighting performance trade‑offs and best‑practice alternatives for concurrent applications.

CollectionsHashMapThread Safety
0 likes · 4 min read
Hashtable vs HashMap: Thread Safety, Null Handling, and Performance Explained
Top Architect
Top Architect
Jan 19, 2025 · Backend Development

Understanding Kafka Consumer: Offset Management, Rebalance, Partition Assignment, and Thread Safety

This article provides a comprehensive technical walkthrough of KafkaConsumer, covering Java configuration code, delivery semantics (at‑most‑once, at‑least‑once, exactly‑once), offset commit strategies, rebalance mechanisms, partition assignment algorithms, thread‑safety concerns, and internal poll implementation, followed by unrelated promotional content.

KafkaOffset ManagementPartition Assignment
0 likes · 16 min read
Understanding Kafka Consumer: Offset Management, Rebalance, Partition Assignment, and Thread Safety
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Jan 17, 2025 · Backend Development

Why Reentrant Locks Prevent Deadlocks and How to Use Them in Java

Reentrant locks are thread‑safe synchronization tools that let the same thread acquire the same lock multiple times without deadlocking, tracking acquisition counts, and offering advantages over traditional synchronized blocks, with Java’s ReentrantLock providing flexible features such as interruptible and timed locking, illustrated by a complete code example.

ReentrantLockThread Safetyconcurrency
0 likes · 6 min read
Why Reentrant Locks Prevent Deadlocks and How to Use Them in Java
IT Services Circle
IT Services Circle
Jan 4, 2025 · Backend Development

Is std::cout Thread‑Safe? Understanding Data Races, Race Conditions, and Practical Solutions in C++

This article examines whether std::cout is thread‑safe, explains the concepts of data race and race condition, demonstrates how interleaved output can occur in multithreaded C++ programs, and presents several solutions—including mutexes, custom wrappers, and C++20 std::osyncstream—to ensure orderly output.

C++Data RaceThread Safety
0 likes · 10 min read
Is std::cout Thread‑Safe? Understanding Data Races, Race Conditions, and Practical Solutions in C++
Test Development Learning Exchange
Test Development Learning Exchange
Dec 28, 2024 · Backend Development

Using asyncio call_soon, call_at, call_later, and call_soon_threadsafe in Python

This article explains how Python's asyncio library schedules callbacks with call_soon, call_at, call_later, and call_soon_threadsafe, providing detailed usage descriptions and multiple example code snippets that demonstrate immediate, absolute‑time, relative‑time, and thread‑safe task scheduling within an event loop.

Thread Safetyasynciocallback-scheduling
0 likes · 6 min read
Using asyncio call_soon, call_at, call_later, and call_soon_threadsafe in Python
Python Programming Learning Circle
Python Programming Learning Circle
Nov 5, 2024 · Fundamentals

Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety

This article explains the Singleton design pattern in Python, covering various implementation methods—including modules, decorators, classic classes, __new__ method, and metaclasses—while demonstrating thread‑safety concerns and solutions with locking, and provides complete code examples for each approach.

Design PatternMetaclassThread Safety
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety
Programmer1970
Programmer1970
Oct 29, 2024 · Backend Development

Master Google Guava’s Multimap to Boost Programming Efficiency

This article explains Guava's Multimap feature, covering its core one‑to‑many mapping capabilities, common methods, various implementations (ArrayListMultimap, HashMultimap, LinkedHashMultimap, TreeMultimap, immutable and synchronized versions), and provides concrete Java code examples and a social‑network scenario to help developers choose the right implementation.

CollectionsGoogle GuavaImmutable
0 likes · 13 min read
Master Google Guava’s Multimap to Boost Programming Efficiency
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Sep 17, 2024 · Backend Development

In‑Depth Explanation of Java ConcurrentHashMap Core Principles and Source Code

This article provides a comprehensive analysis of Java's ConcurrentHashMap, covering its underlying data structures, key attributes, core components such as Node, ForwardingNode, TreeBin, and TreeNode, and detailed explanations of the put, get, hash, and resizing algorithms with annotated source code examples.

ConcurrentHashMapData StructuresHashMap
0 likes · 17 min read
In‑Depth Explanation of Java ConcurrentHashMap Core Principles and Source Code
Top Architect
Top Architect
Aug 7, 2024 · Backend Development

Kafka Consumer Deep Dive: Offset Management, Rebalance Strategies, and Thread Safety

This article explains Kafka consumer semantics such as at‑most‑once, at‑least‑once and exactly‑once delivery, shows how to configure and commit offsets, describes the rebalance process and partition‑assignment strategies, and discusses thread‑safety and task scheduling with illustrative Java code examples.

KafkaThread Safetyconsumer
0 likes · 17 min read
Kafka Consumer Deep Dive: Offset Management, Rebalance Strategies, and Thread Safety
Shepherd Advanced Notes
Shepherd Advanced Notes
Jul 5, 2024 · Backend Development

Why Switch to LocalDateTime? Master Java 8 Date/Time API and Avoid Common Pitfalls

This article explains why the legacy java.util.Date and Calendar APIs are problematic, demonstrates common bugs such as integer overflow, year‑format issues, and SimpleDateFormat thread‑safety, and shows how Java 8's immutable java.time classes like LocalDate, LocalDateTime and DateTimeFormatter provide clear, safe, and concise solutions with practical code examples.

Java 8LocalDateTimeThread Safety
0 likes · 21 min read
Why Switch to LocalDateTime? Master Java 8 Date/Time API and Avoid Common Pitfalls
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Jul 1, 2024 · Backend Development

Resolving Data Contamination in Multithreaded Security Testing by Redesigning Class Attributes in Python

This article explains how using a shared class attribute to store open ports in a Python security‑testing framework can cause data contamination across threads, demonstrates the problem with example code, and presents three solutions—reinitializing the attribute, using contextvars, and employing threading.local—to ensure thread‑local isolation and accurate port scanning.

Class AttributesContextVarPython
0 likes · 10 min read
Resolving Data Contamination in Multithreaded Security Testing by Redesigning Class Attributes in Python
Cognitive Technology Team
Cognitive Technology Team
Jun 23, 2024 · Fundamentals

Understanding Fail-Fast Iterators and ConcurrentModificationException in Java Collections

The article explains why fail‑fast iterators throw ConcurrentModificationException when a collection is modified during iteration, outlines two common scenarios that trigger the exception, and presents both incorrect and correct Java code examples along with strategies such as avoiding modifications, using synchronization, iterator.remove(), or switching to fail‑safe concurrent collections.

CollectionsConcurrentModificationExceptionFail-Fast Iterator
0 likes · 5 min read
Understanding Fail-Fast Iterators and ConcurrentModificationException in Java Collections
Liangxu Linux
Liangxu Linux
May 19, 2024 · Fundamentals

Mastering Thread Safety: Turn Multithreaded Code into a Well‑Behaved Cat

This article explains why multithreaded programs often feel like untamable beasts, introduces the core concept of thread safety, distinguishes private and shared resources, shows concrete C/C++ examples of safe and unsafe patterns, and outlines practical techniques such as thread‑local storage, read‑only globals, atomic operations and synchronization to write reliable concurrent code.

C++LocksThread Safety
0 likes · 15 min read
Mastering Thread Safety: Turn Multithreaded Code into a Well‑Behaved Cat
IT Services Circle
IT Services Circle
May 16, 2024 · Fundamentals

Thread Safety Explained: Private vs Shared Resources and Practical Guidelines

This article demystifies thread safety by comparing private and shared resources, defining when code is thread‑safe, illustrating common pitfalls with C/C++ examples, and presenting practical techniques such as using thread‑local storage, read‑only globals, atomic operations, and synchronization to write reliable multithreaded programs.

Thread Safetyatomic-operationsmultithreading
0 likes · 16 min read
Thread Safety Explained: Private vs Shared Resources and Practical Guidelines
Architect's Guide
Architect's Guide
Apr 28, 2024 · Backend Development

Kafka Consumer Usage Example and Deep Dive into Offset Management, Rebalance, and Thread Safety

This article presents a Java Kafka consumer example, explains offset semantics (at‑most‑once, at‑least‑once, exactly‑once), details consumer rebalance mechanisms, partition assignment strategies, thread‑safety considerations, and showcases core poll, heartbeat, and auto‑commit implementations with accompanying code snippets.

KafkaOffset ManagementThread Safety
0 likes · 14 min read
Kafka Consumer Usage Example and Deep Dive into Offset Management, Rebalance, and Thread Safety
Lobster Programming
Lobster Programming
Apr 22, 2024 · Backend Development

Why SqlSession Is Thread‑Unsafe and How SqlSessionTemplate Ensures Safety

This article explains why MyBatis SqlSession is not thread‑safe, outlines strategies such as using per‑thread instances or ThreadLocal to secure it, and details how Spring's SqlSessionTemplate leverages dynamic proxies and ThreadLocal storage to provide thread‑safe database operations.

MyBatisSqlSessionThread Safety
0 likes · 3 min read
Why SqlSession Is Thread‑Unsafe and How SqlSessionTemplate Ensures Safety
IT Services Circle
IT Services Circle
Apr 17, 2024 · Databases

Comprehensive Didi Interview Review: Redis Persistence, Data Types, Memory Issues, and System Concepts

This article summarizes a Didi second‑round interview covering Redis persistence mechanisms, data structures, memory overflow and leak concepts, thread safety, process vs thread differences, deadlock prevention, TCP/UDP distinctions, and a couple of hand‑written algorithm problems, providing detailed explanations and code examples.

Data StructuresDatabaseInterview
0 likes · 19 min read
Comprehensive Didi Interview Review: Redis Persistence, Data Types, Memory Issues, and System Concepts
Java Captain
Java Captain
Mar 7, 2024 · Backend Development

Applying Java Annotations in Concurrent Programming

This article explores how Java's annotation mechanism, introduced in JDK 5.0, can be leveraged to address concurrency challenges by providing thread-safety, locking, timeout, and asynchronous execution annotations, and discusses their integration with AOP for enhanced thread management and performance.

AOPThread Safetyannotations
0 likes · 5 min read
Applying Java Annotations in Concurrent Programming
MaGe Linux Operations
MaGe Linux Operations
Mar 6, 2024 · Backend Development

Mastering Thread Safety in Python: Locks, Conditions, and More

This article explains thread safety in Python, illustrates race conditions with a shared counter example, and demonstrates how various synchronization primitives—including Lock, RLock, Condition, Event, and Semaphore—can be used to coordinate threads safely and avoid deadlocks.

PythonThread Safetyconcurrency
0 likes · 24 min read
Mastering Thread Safety in Python: Locks, Conditions, and More
Java Captain
Java Captain
Mar 1, 2024 · Backend Development

Using Java Annotations to Solve Concurrency Timing Challenges

The article explains how Java's annotation mechanism, including @ThreadSafe, @NotThreadSafe, @GuardedBy, and @Immutable, can be applied to clarify and manage concurrent behavior, helping developers resolve the timing uncertainties inherent in multithreaded programming.

Thread Safetyannotationsconcurrency
0 likes · 5 min read
Using Java Annotations to Solve Concurrency Timing Challenges
Java Tech Enthusiast
Java Tech Enthusiast
Jan 30, 2024 · Backend Development

Common Intermittent Bugs in Production: Scenarios, Cases, and Prevention

Production teams often face intermittent bugs that slip through local and test environments, typically caused by concurrency issues, cache inconsistencies, mutable shared templates, improper thread‑local cleanup, unsynchronized async tasks, race conditions, and resource failures, so writing thread‑safe code, simulating real traffic, logging clearly, and ensuring graceful shutdowns are essential for prevention.

Thread Safetyconcurrencyintermittent bugs
0 likes · 14 min read
Common Intermittent Bugs in Production: Scenarios, Cases, and Prevention
Architect's Guide
Architect's Guide
Dec 12, 2023 · Backend Development

Understanding Kafka Consumer: Delivery Guarantees, Rebalance Mechanisms, Partition Assignment, and Thread Safety

This article provides a comprehensive guide to KafkaConsumer, covering message delivery semantics (at‑most‑once, at‑least‑once, exactly‑once), practical exactly‑once implementations, consumer rebalance triggers and strategies, partition assignment algorithms, thread‑safety considerations, and detailed Java code examples of the consumer workflow.

KafkaMessage DeliveryThread Safety
0 likes · 14 min read
Understanding Kafka Consumer: Delivery Guarantees, Rebalance Mechanisms, Partition Assignment, and Thread Safety
FunTester
FunTester
Oct 24, 2023 · Backend Development

Using java.util.concurrent.locks.ReentrantLock: Blocking, Interruptible, and Timed Locks in Java

This article explains thread safety in Java multithreading, introduces the ReentrantLock class from java.util.concurrent.locks, demonstrates blocking, interruptible, and timed lock usage with code examples, discusses best practices, fairness, reentrancy, and performance considerations for effective concurrency control.

ReentrantLockThread Safetyconcurrency
0 likes · 8 min read
Using java.util.concurrent.locks.ReentrantLock: Blocking, Interruptible, and Timed Locks in Java
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Sep 18, 2023 · Backend Development

Why MyBatis SqlSession Crashes with Multiple Threads and How Spring Fixes It

This article examines the ClassCastException that occurs when 100 threads concurrently query MyBatis using a shared SqlSession, analyzes the root cause in DefaultSqlSession and BaseExecutor, and explains how Spring Boot’s MyBatis integration employs SqlSessionTemplate, ThreadLocal binding, and transaction management to guarantee thread‑safe SqlSession usage.

MyBatisSpring BootSqlSession
0 likes · 21 min read
Why MyBatis SqlSession Crashes with Multiple Threads and How Spring Fixes It
AI Skills Research
AI Skills Research
Sep 12, 2023 · Fundamentals

Understanding C#'s volatile Keyword for Thread Safety

The article explains how the C# volatile keyword ensures that fields accessed by multiple threads always hold the latest value by preventing compiler optimizations, lists the types it can be applied to, and warns of pitfalls when used with complex data structures.

C++Thread SafetyVolatile
0 likes · 3 min read
Understanding C#'s volatile Keyword for Thread Safety
Selected Java Interview Questions
Selected Java Interview Questions
Aug 31, 2023 · Backend Development

How to Solve SimpleDateFormat Thread Safety Issues in High-Concurrency Scenarios

This article presents several common solutions for addressing the thread‑safety problem of Java's SimpleDateFormat in high‑concurrency environments, including using local variables, synchronized blocks, Lock, ThreadLocal, Java 8 DateTimeFormatter, and Joda‑Time, and evaluates their performance and suitability.

DateTimeFormatterSimpleDateFormatThread Safety
0 likes · 17 min read
How to Solve SimpleDateFormat Thread Safety Issues in High-Concurrency Scenarios
FunTester
FunTester
Aug 2, 2023 · Backend Development

Practical Use of Java ThreadLocal for Thread‑Safe Variable Storage and Real‑World Scenarios

This article explains the Java ThreadLocal class, demonstrates how it provides per‑thread variable isolation to avoid concurrency issues, and shares two real‑world scenarios—including a utility class and a Spring Boot case—showing how ThreadLocal can simplify thread‑local state management while warning about potential memory leaks.

Thread SafetyThreadLocalconcurrency
0 likes · 9 min read
Practical Use of Java ThreadLocal for Thread‑Safe Variable Storage and Real‑World Scenarios
MaGe Linux Operations
MaGe Linux Operations
May 23, 2023 · Fundamentals

Mastering the Singleton Pattern in Python: Thread‑Safe Implementations

This article explains the purpose of the Singleton pattern, demonstrates multiple Python implementations—including module‑based, decorator, class‑based, __new__ method, and metaclass approaches—covers thread‑safety with locking, and provides complete code examples for each technique.

Design PatternMetaclassThread Safety
0 likes · 10 min read
Mastering the Singleton Pattern in Python: Thread‑Safe Implementations
360 Quality & Efficiency
360 Quality & Efficiency
May 19, 2023 · Backend Development

Resolving SimpleDateFormat Thread Safety Issues with ThreadLocal in Java

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the concurrency problem with a multithreaded demo, and presents three solutions—creating new instances, synchronizing access, and using ThreadLocal—highlighting the ThreadLocal approach with code examples and discussion of potential memory‑leak considerations.

SimpleDateFormatThread SafetyThreadLocal
0 likes · 4 min read
Resolving SimpleDateFormat Thread Safety Issues with ThreadLocal in Java
Python Programming Learning Circle
Python Programming Learning Circle
May 13, 2023 · Fundamentals

Implementing the Singleton Pattern in Python: Modules, Decorators, Classes, __new__ Method, and Metaclasses

This article explains the Singleton design pattern in Python, describing why a single instance may be needed, and demonstrates five implementation techniques—including module-level singletons, decorators, class methods, the __new__ method, and metaclasses—while addressing thread‑safety concerns with locking mechanisms.

Design PatternMetaclassThread Safety
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Modules, Decorators, Classes, __new__ Method, and Metaclasses
Programmer DD
Programmer DD
May 11, 2023 · Backend Development

Why Java’s ArrayList addAll Fails Under Concurrency and How to Fix It

This article explains the importance and challenges of concurrent programming, details Java's memory model and synchronization primitives, analyzes a real‑world case where concurrent addAll on ArrayList caused missing UI elements, and demonstrates how using thread‑safe collections resolves the issue.

Thread Safetyarraylistconcurrency
0 likes · 14 min read
Why Java’s ArrayList addAll Fails Under Concurrency and How to Fix It
Sohu Tech Products
Sohu Tech Products
May 4, 2023 · Mobile Development

Understanding Kotlin Lazy Initialization: Usage, Source Code Analysis, and Best Practices

This article explains Kotlin's lazy initialization feature, describes its common usage patterns, dives into the internal source‑code implementations (Synchronized, Publication, and None), discusses thread‑safety concepts such as volatile and CAS, and provides practical recommendations for Android developers.

AndroidKotlinLazy Initialization
0 likes · 11 min read
Understanding Kotlin Lazy Initialization: Usage, Source Code Analysis, and Best Practices
Sanyou's Java Diary
Sanyou's Java Diary
Apr 20, 2023 · Fundamentals

Mastering Java’s synchronized: How It Works, Optimizations & Best Practices

This article explains the Java synchronized keyword, covering its purpose for thread safety, usage on methods and blocks, underlying monitor lock mechanism, JVM bytecode details, lock optimizations such as spin, bias, lightweight and heavyweight locks, and practical examples including singleton implementation and differences from volatile.

Thread Safetylock optimizationmonitor lock
0 likes · 27 min read
Mastering Java’s synchronized: How It Works, Optimizations & Best Practices
IT Services Circle
IT Services Circle
Apr 10, 2023 · Fundamentals

Nine Common Pitfalls of Using Multithreading in Java Applications

Switching from single‑threaded synchronous code to multithreaded asynchronous execution can improve performance, but introduces nine major issues—including missing return values, data loss, ordering problems, thread‑safety, ThreadLocal anomalies, OOM risks, high CPU usage, transaction failures, and service crashes—each explained with Java examples and solutions.

Thread Safetyconcurrencyjava
0 likes · 17 min read
Nine Common Pitfalls of Using Multithreading in Java Applications
JD Cloud Developers
JD Cloud Developers
Apr 5, 2023 · Backend Development

Avoid Common ThreadPool Pitfalls in Java: Best Practices and Gotchas

This article examines frequent mistakes when using Java thread pools—such as improper creation, unreasonable parameters, unreleased local pools, and unsafe concurrent operations—and provides detailed analysis, configuration guidelines, and best‑practice recommendations to prevent memory leaks, deadlocks, and performance issues.

Garbage CollectionThread SafetyThreadPool
0 likes · 17 min read
Avoid Common ThreadPool Pitfalls in Java: Best Practices and Gotchas
JavaEdge
JavaEdge
Feb 7, 2023 · Fundamentals

How to Safeguard Your Code Against Unintended Modifications

The article explains how shared mutable state, such as global or static variables, can cause hard‑to‑debug bugs in multithreaded Java applications, and demonstrates that adopting immutability, pure functions, and event‑sourcing principles eliminates these issues, offering concrete coding guidelines and examples.

Functional ProgrammingImmutabilitySoftware Design
0 likes · 10 min read
How to Safeguard Your Code Against Unintended Modifications
MaGe Linux Operations
MaGe Linux Operations
Jan 13, 2023 · Fundamentals

Why Python’s GIL Slows Multithreading and How It Actually Works

This article explains the purpose and mechanics of Python’s Global Interpreter Lock (GIL), how it serializes bytecode execution on single- and multi‑core CPUs, its impact on I/O‑bound versus CPU‑bound workloads, and why certain operations remain thread‑safe despite the lock.

CPythonGILThread Safety
0 likes · 8 min read
Why Python’s GIL Slows Multithreading and How It Actually Works
Alibaba Cloud Native
Alibaba Cloud Native
Dec 20, 2022 · Backend Development

Why Does Instrumentation.appendToSystemClassLoaderSearch Fail in Containers? A Deep Dive into Java Agent, JNI, and Thread‑Safety

This article investigates intermittent Java Agent errors caused by Instrumentation.appendToSystemClassLoaderSearch in container environments, tracing the issue through JNI calls, glibc stat failures, locale‑dependent iconv conversion, and ultimately fixing it with pthread thread‑local storage and proxy wrappers.

IConvJNIJava Agent
0 likes · 11 min read
Why Does Instrumentation.appendToSystemClassLoaderSearch Fail in Containers? A Deep Dive into Java Agent, JNI, and Thread‑Safety
Tuanzi Tech Team
Tuanzi Tech Team
Nov 8, 2022 · Backend Development

Why Does SimpleDateFormat Fail in Multithreaded Java? Solutions and Best Practices

An operation team discovered that QR code redirects returned 404 due to expired access tokens, traced to SimpleDateFormat’s thread‑unsafe parsing causing incorrect expiration dates; the article analyzes the root cause, demonstrates failing multithreaded tests, and presents four thread‑safe alternatives including local instances, synchronization, ThreadLocal, and Java 8’s DateTimeFormatter.

DateTimeFormatterSimpleDateFormatSpringBoot
0 likes · 10 min read
Why Does SimpleDateFormat Fail in Multithreaded Java? Solutions and Best Practices
Code Ape Tech Column
Code Ape Tech Column
Oct 26, 2022 · Databases

In‑Depth Analysis of Druid Connection‑Pool Lifecycle and Internal Processes

This article provides a comprehensive walkthrough of Druid's connection‑pool architecture, detailing the initialization, acquisition, validation, eviction, and recycling of connections, while explaining key configuration options, thread‑safety mechanisms, and performance considerations for Java database applications.

Connection PoolDatabaseDruid
0 likes · 23 min read
In‑Depth Analysis of Druid Connection‑Pool Lifecycle and Internal Processes
Cognitive Technology Team
Cognitive Technology Team
Oct 5, 2022 · Fundamentals

Various Singleton Pattern Implementations in Java

This article explains multiple Java singleton implementations—including eager initialization, static block, lazy initialization, double‑checked locking, static inner‑class holder, and enum—detailing their code, thread‑safety characteristics, advantages, and limitations such as reflection and serialization issues.

Design PatternThread Safetyjava
0 likes · 7 min read
Various Singleton Pattern Implementations in Java
Xiaohongshu Tech REDtech
Xiaohongshu Tech REDtech
Sep 16, 2022 · Mobile Development

Optimizing Android AsyncLayoutInflater for Thread Safety and Performance

Xiaohongshu refactored Android’s AsyncLayoutInflater by introducing a configurable thread‑pool, safe object pools, and a singleton ViewCache, eliminating ArrayMap and LayoutInflater lock issues, which together yielded over 20% faster cold‑starts and page loads, demonstrating significant performance and business benefits.

AndroidAsyncLayoutInflaterThread Safety
0 likes · 9 min read
Optimizing Android AsyncLayoutInflater for Thread Safety and Performance
Code Ape Tech Column
Code Ape Tech Column
Sep 16, 2022 · Backend Development

Ensuring Thread Safety for Spring Singleton Beans: Problems and Solutions

This article explains why Spring singleton beans can be unsafe in concurrent scenarios, demonstrates the issue with a controller example, and presents multiple solutions including changing bean scope, using ThreadLocal, avoiding member variables, employing concurrent collections, and leveraging distributed caches.

Bean ScopeSpringThread Safety
0 likes · 8 min read
Ensuring Thread Safety for Spring Singleton Beans: Problems and Solutions
FunTester
FunTester
Sep 5, 2022 · Backend Development

How Many QPS Are Needed to Reveal Thread‑Unsafe Bugs? A Hands‑On SpringBoot Test

This article explores the QPS threshold required to expose thread‑unsafe operations such as i++ by designing a SpringBoot service, running controlled load tests with both fixed‑thread and precise‑QPS models, and presenting detailed results that show how error rates increase with higher request rates.

Performance TestingQPSSpringBoot
0 likes · 8 min read
How Many QPS Are Needed to Reveal Thread‑Unsafe Bugs? A Hands‑On SpringBoot Test
Python Programming Learning Circle
Python Programming Learning Circle
Aug 10, 2022 · Fundamentals

Implementing Thread‑Safe Singleton Pattern in Python

This article explains the purpose of the Singleton design pattern, demonstrates multiple Python implementations—including module‑level singletons, decorators, class‑based approaches, __new__ method, and metaclass techniques—and shows how to add thread‑safety with locks to ensure only one instance exists across concurrent executions.

Design PatternLockMetaclass
0 likes · 10 min read
Implementing Thread‑Safe Singleton Pattern in Python
Cognitive Technology Team
Cognitive Technology Team
Jul 24, 2022 · Fundamentals

Introduction to ThreadLocal in Java

ThreadLocal provides thread confinement in Java, allowing each thread to hold its own independent variable, which is useful for scenarios such as database connection isolation, transaction storage, lock-free concurrency, implicit parameter passing across functions, and highlights common pitfalls like information loss in thread pools and OOM risks.

Implicit ParametersThread SafetyThreadLocal
0 likes · 5 min read
Introduction to ThreadLocal in Java
Java Architect Essentials
Java Architect Essentials
Jul 3, 2022 · Backend Development

Thread Safety Issues of SimpleDateFormat.parse() and format() Methods and Their Solutions

This article explains why SimpleDateFormat.parse() and SimpleDateFormat.format() are not thread‑safe in Java, analyzes the underlying causes involving shared Calendar objects, and presents three practical solutions—including per‑thread instances, synchronized blocks, and ThreadLocal usage—to eliminate concurrency bugs.

Date ParsingSimpleDateFormatThread Safety
0 likes · 11 min read
Thread Safety Issues of SimpleDateFormat.parse() and format() Methods and Their Solutions
Selected Java Interview Questions
Selected Java Interview Questions
Jun 8, 2022 · Backend Development

Elegant and Efficient Singleton Implementations in Java

This article explores various Java singleton patterns—including eager initialization, static blocks, lazy initialization, double‑checked locking, volatile variables, static inner‑class holder, and serialization handling—explaining their mechanisms, thread‑safety concerns, and how to choose the most appropriate implementation for robust, high‑performance backend systems.

Design PatternThread Safetysingleton
0 likes · 10 min read
Elegant and Efficient Singleton Implementations in Java
Su San Talks Tech
Su San Talks Tech
Jun 7, 2022 · Backend Development

10 Proven Techniques to Ensure Thread Safety in Java Backend Development

This article explains why thread safety is critical for backend developers, describes common data race problems, and provides ten practical strategies—including stateless design, immutability, synchronized blocks, locks, distributed locks, volatile variables, ThreadLocal, concurrent collections, CAS, and data isolation—to reliably protect shared resources in multithreaded Java applications.

Thread Safetydistributed lockjava
0 likes · 13 min read
10 Proven Techniques to Ensure Thread Safety in Java Backend Development
Java Backend Technology
Java Backend Technology
May 23, 2022 · Backend Development

Is Your Spring MVC Controller Thread‑Safe? Understand and Fix It

This article explains what thread safety means, demonstrates how a simple counter can become unsafe under concurrent requests, shows Java code examples of the problem and its synchronized solution, and provides practical guidelines for ensuring Spring MVC controllers remain thread‑safe by avoiding shared mutable state or using synchronization mechanisms such as synchronized blocks or ThreadLocal.

ControllerJava concurrencyThread Safety
0 likes · 5 min read
Is Your Spring MVC Controller Thread‑Safe? Understand and Fix It
Top Architect
Top Architect
Apr 29, 2022 · Backend Development

Understanding Spring MVC Controller Singleton Scope and Thread Safety

The article explains that Spring MVC Controllers are singleton beans by default, discusses the thread‑safety risks of using instance variables in such Controllers, and presents several solutions—including prototype scope, ThreadLocal, and AtomicInteger—to ensure safe concurrent handling of requests.

ControllerThread Safetybackend development
0 likes · 7 min read
Understanding Spring MVC Controller Singleton Scope and Thread Safety
IT Architects Alliance
IT Architects Alliance
Apr 29, 2022 · Fundamentals

Why Your Java Producer‑Consumer Code Deadlocks and How to Fix It

This article explains the root causes of thread‑safety problems in Java producer‑consumer scenarios, demonstrates how race conditions and deadlocks arise, and provides step‑by‑step solutions using synchronized blocks, wait/notify, notifyAll, and explicit Lock with Condition objects.

DeadlockLockThread Safety
0 likes · 20 min read
Why Your Java Producer‑Consumer Code Deadlocks and How to Fix It
Top Architect
Top Architect
Apr 27, 2022 · Fundamentals

Understanding Thread Safety, Synchronization, and Locks in Java

This article explains the fundamentals of thread safety in Java, illustrating common pitfalls in producer‑consumer scenarios, demonstrating how synchronized, wait/notify, and the explicit Lock/Condition mechanisms can be used to avoid data races, deadlocks, and inconsistent state while providing complete code examples.

LockThread Safetyconcurrency
0 likes · 20 min read
Understanding Thread Safety, Synchronization, and Locks in Java
IT Services Circle
IT Services Circle
Mar 18, 2022 · Fundamentals

Understanding Meyers' Singleton in C++: Why Static Local Variables Matter

This article explains the proper C++ singleton implementation known as Meyers' Singleton, showing how a static local variable inside a getInstance() function ensures thread‑safe lazy initialization, avoids static‑initialization‑order problems, and handles inheritance correctly.

C++Design PatternMeyers Singleton
0 likes · 6 min read
Understanding Meyers' Singleton in C++: Why Static Local Variables Matter
Code Ape Tech Column
Code Ape Tech Column
Mar 17, 2022 · Databases

Understanding the Druid Connection Pool Lifecycle and Management

This article provides a comprehensive walkthrough of Druid's connection pool lifecycle, detailing how getConnection initiates the process, the role of initialization, filter chains, connection validation, thread‑blocking strategies, and the various guardian threads that add, evict, and recycle connections to ensure performance and stability.

Connection PoolDatabaseDruid
0 likes · 24 min read
Understanding the Druid Connection Pool Lifecycle and Management