Tagged articles
221 articles
Page 1 of 3
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 reviewPRbest practices
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.

ConcurrentHashMapatomicconcurrency
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.

FastCacheGolocal cache
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.

Stringjavastringbuffer
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++11Design Patternsc++
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.

LockReentrantLockjava
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
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 Patternsbackend interviewjava
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 PatternsImmutableconcurrency
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.

Time Zonespring-bootthread safety
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 APIcommon mistakesjava
0 likes · 11 min read
Avoid These 7 Common Java Stream Mistakes for Cleaner, Faster Code
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.

ConcurrentHashMapjavaspring
0 likes · 13 min read
When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety
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.

ConsumerKafkaOffset Management
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.

ReentrantLockconcurrencyjava
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 racemutex
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.

asynciocallback-schedulingevent loop
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.

DecoratorMetaclassSingleton
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety
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.

ConsumerKafkaOFFSET
0 likes · 17 min read
Kafka Consumer Deep Dive: Offset Management, Rebalance Strategies, and Thread Safety
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++Locksmultithreading
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.

atomic operationsmultithreadingshared resources
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.

ConsumerKafkaOffset Management
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.

SqlSessionmybatisthread 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.

Timeoutannotationsaop
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.

PythonSynchronizationconcurrency
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.

annotationsconcurrencyjava
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.

concurrencyintermittent bugsproduction debugging
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.

ConsumerKafkaMessage Delivery
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.

ReentrantLockconcurrencyjava
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.

SqlSessionmybatisspring-boot
0 likes · 21 min read
Why MyBatis SqlSession Crashes with Multiple Threads and How Spring Fixes It
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.

DateTimeFormatterSimpleDateFormatThreadLocal
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.

ThreadLocalconcurrencyjava
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.

MetaclassSingletondesign pattern
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.

SimpleDateFormatThreadLocalconcurrency
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.

MetaclassSingletondesign pattern
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.

ArrayListJMMconcurrency
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.

AndroidKotlinMobile Development
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.

lock optimizationmonitor locksynchronized
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.

concurrencyjavamultithreading
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 CollectionThreadPoolconcurrency
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 programmingimmutabilityjava
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.

CPythonGILmultithreading
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.

ContainerIConvJNI
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 PoolDruiddatabase
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.

Singletondesign patternjava
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.

AndroidAsyncLayoutInflaterMobile Development
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.

BackendBean ScopeSingleton
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.

DecoratorLockMetaclass
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 ParametersThreadLocalconcurrency
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 ParsingSimpleDateFormatSynchronization
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.

Singletondesign patternthread safety
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.

distributed-lockjavathread safety
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 concurrencySpring MVC
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.

ControllerSingletonSpring MVC
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.

LockProducer Consumerconcurrency
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.

LockSynchronizationconcurrency
0 likes · 20 min read
Understanding Thread Safety, Synchronization, and Locks in Java
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 PoolDruiddatabase
0 likes · 24 min read
Understanding the Druid Connection Pool Lifecycle and Management
Code Ape Tech Column
Code Ape Tech Column
Mar 10, 2022 · Backend Development

10 Common Pitfalls in Java Concurrency and How to Avoid Them

This article outlines ten typical concurrency pitfalls in Java—including SimpleDateFormat thread‑safety, double‑checked locking flaws, volatile atomicity limits, deadlocks, lock release issues, HashMap race conditions, default thread‑pool misuse, @Async thread explosion, spin‑lock CPU waste, and ThreadLocal memory leaks—providing explanations, code examples, and practical solutions for each.

concurrencyjavamultithreading
0 likes · 20 min read
10 Common Pitfalls in Java Concurrency and How to Avoid Them
IT Services Circle
IT Services Circle
Mar 7, 2022 · Backend Development

10 Common Java Concurrency Pitfalls and How to Avoid Them

This article outlines ten frequent Java concurrency pitfalls—including unsafe SimpleDateFormat usage, double‑checked locking flaws, volatile limitations, deadlocks, HashMap memory leaks, thread‑pool misuse, @Async traps, spin‑lock inefficiencies, and ThreadLocal memory leaks—providing explanations, code examples, and practical solutions for each.

best practicesconcurrencyperformance
0 likes · 21 min read
10 Common Java Concurrency Pitfalls and How to Avoid Them
Zhuanzhuan Tech
Zhuanzhuan Tech
Jan 26, 2022 · Fundamentals

Understanding the Happens‑Before Principle in Java Concurrency

This article explains the Java Happens‑Before principle, detailing its rules such as program order, monitor lock, volatile variable, thread start, termination, interruption, and finalizer, and demonstrates each rule with clear code examples to illustrate visibility guarantees in concurrent programming.

Happens-beforeMemory Modeljava
0 likes · 28 min read
Understanding the Happens‑Before Principle in Java Concurrency
Java Interview Crash Guide
Java Interview Crash Guide
Jan 14, 2022 · Fundamentals

How Does Java’s ThreadLocal Avoid Memory Leaks? Deep Dive into Its Design

This article explores Java's thread‑local storage, explaining why shared variables cause thread‑safety issues, how a proxy can hide object retrieval, the pitfalls of a naive Map‑based design that leads to memory leaks, and how the JDK's ThreadLocal uses weak references and ThreadLocalMap to safely manage per‑thread data.

ThreadLocaljavamemory leak
0 likes · 8 min read
How Does Java’s ThreadLocal Avoid Memory Leaks? Deep Dive into Its Design
DeWu Technology
DeWu Technology
Dec 26, 2021 · Fundamentals

Java Synchronized Mechanism Overview

Java's synchronized keyword provides mutual exclusion by using object monitors, offering class‑method, static‑method, and block locking patterns, while the JVM optimizes performance through biased, lightweight, and heavyweight lock strategies, making it essential knowledge for efficient concurrent programming.

JVMSynchronizationconcurrency
0 likes · 29 min read
Java Synchronized Mechanism Overview
Selected Java Interview Questions
Selected Java Interview Questions
Nov 29, 2021 · Backend Development

Understanding Synchronized and Concurrent Containers in Java

The article explains Java's synchronized containers such as Vector, Stack, and Hashtable, demonstrates their usage and pitfalls, then introduces concurrent containers like ConcurrentHashMap, CopyOnWriteArrayList, and ConcurrentSkipListSet, providing code examples and best practices for thread‑safe collection handling.

Collections FrameworkConcurrent ContainersSynchronized Collections
0 likes · 17 min read
Understanding Synchronized and Concurrent Containers in Java
Java Tech Enthusiast
Java Tech Enthusiast
Nov 18, 2021 · Fundamentals

Pessimistic and Optimistic Locks in Java: Theory and Code Examples

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.

CASLocksconcurrency
0 likes · 11 min read
Pessimistic and Optimistic Locks in Java: Theory and Code Examples
FunTester
FunTester
Nov 5, 2021 · Backend Development

Master Java ReentrantLock: Simple Thread‑Safe Coding Without synchronized

This article introduces Java's ReentrantLock as an easy-to‑use alternative to synchronized, explains its core lock() and unlock() methods, demonstrates practical code examples, and covers advanced APIs such as tryLock, getQueueLength, isLocked, and getHoldCount for robust multithreaded programming.

BackendReentrantLockconcurrency
0 likes · 5 min read
Master Java ReentrantLock: Simple Thread‑Safe Coding Without synchronized