Tagged articles
205 articles
Page 2 of 3
Selected Java Interview Questions
Selected Java Interview Questions
Nov 17, 2022 · Backend Development

Spring Boot Login Authentication: Filters, Interceptors, AOP, ThreadLocal, and Parameter Resolver

This article presents a comprehensive Spring Boot tutorial on implementing non‑intrusive login authentication using three techniques—Filter, Interceptor, and AOP with custom annotations—plus extensions such as ThreadLocal storage and a Spring MVC argument resolver, complete with project setup, Maven dependencies, and test screenshots.

InterceptorParameter ResolverSpring Boot
0 likes · 13 min read
Spring Boot Login Authentication: Filters, Interceptors, AOP, ThreadLocal, and Parameter Resolver
Cognitive Technology Team
Cognitive Technology Team
Oct 3, 2022 · Backend Development

Spring Boot 2.7.1 Upgrade Alters AOP Advice Execution Order and Causes ThreadLocal Loss

After upgrading to Spring Boot 2.7.1 (Spring Framework 5.3.21), the execution order of @Around, @Before, and @After advice changes, leading to ThreadLocal data loss inside @Around, and the article explains the cause, reproduces the issue, and recommends using only @Around for reliable logic.

Advice OrderBackend DevelopmentSpring Boot
0 likes · 4 min read
Spring Boot 2.7.1 Upgrade Alters AOP Advice Execution Order and Causes ThreadLocal Loss
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Sep 27, 2022 · Backend Development

Four Common Ways to Implement Thread Synchronization in Java

This article explains the concept of thread synchronization in Java and provides detailed examples of four implementation methods—using the synchronized keyword, ReentrantLock, atomic variables, and ThreadLocal—along with code snippets and a comparison of their advantages and usage scenarios.

ReentrantLockThreadLocalatomic
0 likes · 6 min read
Four Common Ways to Implement Thread Synchronization in Java
Java Architect Essentials
Java Architect Essentials
Sep 26, 2022 · Backend Development

Understanding Netty's FastThreadLocal: Background, Implementation, and Usage

This article explains why Netty created FastThreadLocal, describes its internal design and source‑code analysis—including UnpaddedInternalThreadLocalMap, InternalThreadLocalMap, FastThreadLocalThread, and FastThreadLocal implementations—covers performance degradation in ordinary threads, outlines its three resource‑recycling mechanisms, and shows how it is used for ByteBuf allocation in Netty.

FastThreadLocalNettyThreadLocal
0 likes · 14 min read
Understanding Netty's FastThreadLocal: Background, Implementation, and Usage
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
Programmer DD
Programmer DD
Aug 21, 2022 · Backend Development

Why PageHelper Can Break Your MyBatis Queries: Hidden ThreadLocal Pitfalls

This article examines unexpected bugs caused by PageHelper in a Java/MyBatis project—such as duplicate registrations, limited dropdown results, and password‑reset errors—traces them to ThreadLocal misuse, explains the library’s internal pagination flow, and offers practical fixes to avoid these pitfalls.

JavaMyBatisSQL
0 likes · 14 min read
Why PageHelper Can Break Your MyBatis Queries: Hidden ThreadLocal Pitfalls
Su San Talks Tech
Su San Talks Tech
Aug 14, 2022 · Backend Development

9 Hidden Pitfalls When Converting Synchronous Code to Multithreaded Execution

Switching from single‑threaded synchronous calls to multithreaded asynchronous execution can boost performance, but it also introduces nine common problems—including missing return values, data loss, ordering issues, thread‑safety bugs, ThreadLocal anomalies, OOM, high CPU usage, transaction failures, and service crashes—that developers must understand and mitigate.

JavaThreadLocalThreadPool
0 likes · 19 min read
9 Hidden Pitfalls When Converting Synchronous Code to Multithreaded Execution
Selected Java Interview Questions
Selected Java Interview Questions
Aug 13, 2022 · Backend Development

Understanding PageHelper Pagination Issues and ThreadLocal Management in MyBatis

This article explains how PageHelper integrates with MyBatis, analyzes common pagination bugs such as unexpected LIMIT clauses, duplicate registrations, and password‑reset errors, and demonstrates the internal ThreadLocal handling, startPage usage, and proper cleanup to avoid thread‑local pollution.

MyBatisThreadLocalpagehelper
0 likes · 12 min read
Understanding PageHelper Pagination Issues and ThreadLocal Management in MyBatis
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 ParametersJavaThreadLocal
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
Code Ape Tech Column
Code Ape Tech Column
Jun 2, 2022 · Backend Development

Using Alibaba's TransmittableThreadLocal to Propagate ThreadLocal Variables in Thread Pools

This article explains why InheritableThreadLocal fails in pooled threads, introduces Alibaba's TransmittableThreadLocal library, demonstrates how to wrap executors and rewrite code to correctly transmit ThreadLocal data across parent‑child threads in Java thread pools, and provides detailed implementation and usage examples.

JavaThreadLocalThreadPool
0 likes · 13 min read
Using Alibaba's TransmittableThreadLocal to Propagate ThreadLocal Variables in Thread Pools
DaTaobao Tech
DaTaobao Tech
May 25, 2022 · Backend Development

Best Practices for Java Thread Pools and ThreadLocal in Backend Development

The article outlines Java thread‑pool fundamentals, explains ThreadPoolExecutor parameters and Tomcat’s custom pool behavior, and provides best‑practice guidelines for creating pools directly, configuring rejection policies, and safely using ThreadLocal—including static declarations, proper cleanup, and avoiding memory‑leak pitfalls—to build stable, high‑performance backend services.

BackendJavaThreadLocal
0 likes · 32 min read
Best Practices for Java Thread Pools and ThreadLocal in 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
Su San Talks Tech
Su San Talks Tech
May 14, 2022 · Backend Development

Unlocking ThreadLocal: How Java Manages Thread‑Local Data and Avoids Memory Leaks

This article explains why ThreadLocal is used in Java concurrency, dives into its internal implementation—including ThreadLocalMap, weak‑referenced keys, hash‑based indexing and resizing—covers common pitfalls such as memory leaks, and shows how InheritableThreadLocal and TransmittableThreadLocal can safely share data across child threads and thread pools.

InheritableThreadLocalJavaMemoryLeak
0 likes · 24 min read
Unlocking ThreadLocal: How Java Manages Thread‑Local Data and Avoids Memory Leaks
Selected Java Interview Questions
Selected Java Interview Questions
May 5, 2022 · Backend Development

Understanding ThreadLocal in Java: Principles, Memory Leak Issues, and Proper Usage

This article explains Java's ThreadLocal mechanism, detailing its internal structure, including key methods like set, get, and remove, demonstrates how improper use can cause memory leaks, and provides best practices and examples for safe usage, including InheritableThreadLocal and real-world scenarios.

InheritableThreadLocalThreadLocalbest practices
0 likes · 18 min read
Understanding ThreadLocal in Java: Principles, Memory Leak Issues, and Proper Usage
Cognitive Technology Team
Cognitive Technology Team
Apr 25, 2022 · Backend Development

Preventing ThreadLocal Information Loss in Multithreaded Java Applications by Implementing Custom Runnable and Callable (Hystrix Example)

This article explains why ThreadLocal variables can lose their values when used across thread pools, and demonstrates how to create custom Runnable and Callable wrappers that propagate HystrixRequestContext to ensure reliable ThreadLocal transmission in multithreaded Java environments.

CallableContextPropagationHystrix
0 likes · 8 min read
Preventing ThreadLocal Information Loss in Multithreaded Java Applications by Implementing Custom Runnable and Callable (Hystrix Example)
Cognitive Technology Team
Cognitive Technology Team
Apr 24, 2022 · Backend Development

Pitfalls of Using ThreadLocal for User Context in Java Applications

Using ThreadLocal to store user information in Java web applications can lead to hidden failures such as loss of context and memory leaks, especially when thread pools are involved, so developers should restrict its usage to controller threads and employ static analysis tools to detect improper usage.

JavaMemoryLeakThreadLocal
0 likes · 4 min read
Pitfalls of Using ThreadLocal for User Context in Java Applications
Selected Java Interview Questions
Selected Java Interview Questions
Apr 4, 2022 · Backend Development

Using InheritableThreadLocal to Access Parent ThreadLocal Values in Child Threads (Java)

This article explains how to make a child thread inherit the values stored in a parent thread's ThreadLocal by using InheritableThreadLocal, demonstrates the behavior with a runnable Java example, and details the underlying ThreadLocalMap mechanism that enables the inheritance.

Backend DevelopmentInheritableThreadLocalThreadLocal
0 likes · 3 min read
Using InheritableThreadLocal to Access Parent ThreadLocal Values in Child Threads (Java)
Dada Group Technology
Dada Group Technology
Mar 25, 2022 · Backend Development

Optimizing Log4j2 Logging: Reducing Disk and CPU Usage, Asynchronous Logging, and Traceability with ThreadLocal and TTL

This article presents a comprehensive approach to optimizing Log4j2 logging in high‑traffic Java services by reducing disk and CPU consumption through log level control and pattern tuning, adopting asynchronous logging, and enabling end‑to‑end request traceability using ThreadLocal, TransmittableThreadLocal, and MDC techniques, supported by performance test results and practical recommendations.

JavaResource OptimizationTTL
0 likes · 14 min read
Optimizing Log4j2 Logging: Reducing Disk and CPU Usage, Asynchronous Logging, and Traceability with ThreadLocal and TTL
Top Architect
Top Architect
Jan 17, 2022 · Backend Development

Using SLF4J MDC to Correlate Logs Across Threads in Java Applications

This article explains how to employ SLF4J's MDC feature to attach a request identifier to log entries, demonstrates why it fails in asynchronous threads, and shows how to fix the issue with a decorator‑style MDCRunnable that propagates the MDC context to child threads and thread pools.

Decorator PatternJavaThreadLocal
0 likes · 10 min read
Using SLF4J MDC to Correlate Logs Across Threads in Java Applications
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.

JavaThreadLocalmemory leak
0 likes · 8 min read
How Does Java’s ThreadLocal Avoid Memory Leaks? Deep Dive into Its Design
Programmer DD
Programmer DD
Oct 13, 2021 · Backend Development

Why Netty Introduced FastThreadLocal and How It Works

This article explains the motivation behind Netty's FastThreadLocal, compares it with JDK ThreadLocal, details its internal implementation—including InternalThreadLocalMap, FastThreadLocalThread, and key methods like get()—and discusses its performance benefits, resource recycling mechanisms, and practical usage in Netty's ByteBuf allocation.

FastThreadLocalJavaMemory Management
0 likes · 13 min read
Why Netty Introduced FastThreadLocal and How It Works
Programmer DD
Programmer DD
Sep 26, 2021 · Backend Development

Mastering ThreadLocal in Java: When and How to Use It Safely

This article explains the two primary use cases of ThreadLocal in Java—providing each thread with its own exclusive object and sharing request‑scoped data across methods—while covering implementation details, memory‑leak risks, and best‑practice cleanup techniques.

Backend DevelopmentJavaThreadLocal
0 likes · 10 min read
Mastering ThreadLocal in Java: When and How to Use It Safely
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Sep 9, 2021 · Backend Development

Uncovering How SpringBoot Injects HttpServletRequest via ThreadLocal and Dynamic Proxies

This article explains how SpringBoot injects HttpServletRequest into controllers using a JDK dynamic proxy and ThreadLocal storage, tracing the request object from the ObjectFactoryDelegatingInvocationHandler through RequestObjectFactory, RequestContextHolder, and the FrameworkServlet's processRequest lifecycle.

Backend DevelopmentDynamic ProxyHttpServletRequest
0 likes · 7 min read
Uncovering How SpringBoot Injects HttpServletRequest via ThreadLocal and Dynamic Proxies
Wukong Talks Architecture
Wukong Talks Architecture
Aug 17, 2021 · Fundamentals

Core Java Multithreading Interview Questions and Concepts

This article compiles 16 classic Java multithreading interview questions covering high‑concurrency containers, CAS and ABA problems, volatile vs synchronized, the Java Memory Model, ThreadLocal drawbacks, AQS, thread‑pool architecture, queue types, sizing strategies, rejection policies, lifecycle management, and graceful shutdown techniques.

CASJMMJava
0 likes · 20 min read
Core Java Multithreading Interview Questions and Concepts
Programmer DD
Programmer DD
Jul 23, 2021 · Fundamentals

Why Overriding hashCode Matters: Prevent Memory Leaks and OOM

This article explores the distinction between OutOfMemory errors and memory leaks in Java, examines how improper use of static fields, unclosed streams, incorrect equals/hashCode implementations, and ThreadLocal can cause leaks, and provides practical solutions and tools such as JVisualVM to detect and prevent these issues.

JVMJavaOutOfMemory
0 likes · 16 min read
Why Overriding hashCode Matters: Prevent Memory Leaks and OOM
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Jul 17, 2021 · Backend Development

How to Preserve Trace Context Across Asynchronous Java Threads with TransmittableThreadLocal

This article explains why ThreadLocal‑based trace information is lost in asynchronous Java calls, compares InheritableThreadLocal and the Alibaba‑provided TransmittableThreadLocal library, shows how to wrap runnables with TtlRunnable, and demonstrates a Java Agent solution for transparent thread‑pool propagation.

InheritableThreadLocalJavaThreadLocal
0 likes · 9 min read
How to Preserve Trace Context Across Asynchronous Java Threads with TransmittableThreadLocal
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Jul 14, 2021 · Backend Development

Mastering SLF4J MDC for Precise Log Tracing in Multi‑Threaded Java Applications

This article explains how SLF4J’s Mapped Diagnostic Context (MDC) leverages ThreadLocal to embed trace and span identifiers into log messages, demonstrates configuring log4j2 patterns, shows code for injecting and clearing MDC values during span lifecycle, and addresses MDC propagation in asynchronous threads using Transmittable ThreadLocal.

ThreadLocallog4j2mdc
0 likes · 4 min read
Mastering SLF4J MDC for Precise Log Tracing in Multi‑Threaded Java Applications
Su San Talks Tech
Su San Talks Tech
Jun 19, 2021 · Backend Development

How a Hidden NPE Revealed Deep Issues in Our Java Backend and RocketMQ Integration

After receiving a Sentry alert for a NullPointerException in a Java backend, the author traced the issue through user context handling with TransmittableThreadLocal, uncovered mismatched RocketMQ header propagation, multiple retry attempts, and a manual message injection, ultimately revealing how a missing header caused the NPE.

BackendNPERocketMQ
0 likes · 18 min read
How a Hidden NPE Revealed Deep Issues in Our Java Backend and RocketMQ Integration
IT Xianyu
IT Xianyu
Jun 16, 2021 · Databases

Understanding Database Connection Pools vs. ThreadLocal in Java

This article explains the fundamental differences between database connection pools and ThreadLocal‑cached connections in Java, illustrating how connection pools improve performance while ThreadLocal enables sharing a single connection across methods within the same thread for consistent transaction control, and discusses practical usage patterns.

Backend DevelopmentConnection PoolJava
0 likes · 7 min read
Understanding Database Connection Pools vs. ThreadLocal in Java
Java Architect Essentials
Java Architect Essentials
Jun 1, 2021 · Information Security

API Security Practices: Token, Timestamp, Signature, and Replay Prevention in Spring Boot

This article explains how to protect data exchange with third‑party systems by using access tokens, timestamps, cryptographic signatures, and duplicate‑submission safeguards, providing detailed Java/Spring Boot examples and code snippets for implementing secure API authentication and request validation.

API SecurityJavaSpring Boot
0 likes · 27 min read
API Security Practices: Token, Timestamp, Signature, and Replay Prevention in Spring Boot
Java Backend Technology
Java Backend Technology
May 29, 2021 · Backend Development

Avoid Hidden ThreadLocal Pitfalls: Memory Leaks, Context Loss in Thread Pools & Parallel Streams

This article explains three common ThreadLocal misuse traps—memory leaks caused by weak‑referenced keys, loss of thread‑local context in thread‑pool workers, and context disappearance in parallel streams—provides detailed code examples, and offers practical guidelines to prevent them in Java backend applications.

JavaParallel StreamThreadLocal
0 likes · 9 min read
Avoid Hidden ThreadLocal Pitfalls: Memory Leaks, Context Loss in Thread Pools & Parallel Streams
Programmer DD
Programmer DD
May 21, 2021 · Backend Development

ThreadLocal & ConcurrentHashMap: Hidden Bugs in Java Concurrency

This article examines common misconceptions when using Java concurrency utilities such as ThreadLocal, ConcurrentHashMap, and CopyOnWriteArrayList, demonstrates real‑world bugs caused by thread reuse and improper atomic operations, and provides practical solutions—including explicit cleanup, proper locking, and high‑performance alternatives like computeIfAbsent and LongAdder—to ensure thread‑safe and efficient code.

ConcurrentHashMapCopyOnWriteArrayListJava
0 likes · 12 min read
ThreadLocal & ConcurrentHashMap: Hidden Bugs in Java Concurrency
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 19, 2021 · Backend Development

Understanding ThreadLocal in Java: Concepts, Memory‑Leak Risks, Source‑Code Walkthrough, and Best Practices

This article explains what ThreadLocal is, demonstrates how it works with and without it, analyses its source code, discusses potential memory‑leak issues, and provides best‑practice guidelines and a Spring‑Boot example for safe usage in multithreaded Java applications.

JavaSpring BootThreadLocal
0 likes · 12 min read
Understanding ThreadLocal in Java: Concepts, Memory‑Leak Risks, Source‑Code Walkthrough, and Best Practices
Top Architect
Top Architect
May 18, 2021 · Databases

Understanding Database Connection Pools and ThreadLocal in Java for Transaction Management

This article explains the fundamental differences between database connection pools and ThreadLocal, how each is used in Java to improve performance and enable cross‑method transaction control, and provides practical code examples and best‑practice guidelines for managing connections in multi‑threaded applications.

Backend DevelopmentDatabase Connection PoolJava
0 likes · 7 min read
Understanding Database Connection Pools and ThreadLocal in Java for Transaction Management
Java Backend Technology
Java Backend Technology
May 16, 2021 · Backend Development

Why ThreadLocal and Connection Pools Differ: Master Transaction Management in Java

This article explains the fundamental differences between database connection pools and ThreadLocal in Java, showing how pools improve performance while ThreadLocal enables sharing a single connection across a thread for seamless transaction control, and clarifies common misconceptions with code examples and practical insights.

Connection PoolJavaThreadLocal
0 likes · 6 min read
Why ThreadLocal and Connection Pools Differ: Master Transaction Management in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 15, 2021 · Backend Development

Using ThreadLocal in Java: Scenarios, Thread‑Safety Problems, and Practical Solutions

This article explains why ThreadLocal is both simple and tricky to use, demonstrates common pitfalls when formatting dates with SimpleDateFormat in multithreaded environments, analyzes thread‑safety issues, and provides practical solutions using synchronized blocks, ThreadLocal, and its advanced initialization methods for clean and efficient concurrent code.

JavaThreadLocalconcurrency
0 likes · 20 min read
Using ThreadLocal in Java: Scenarios, Thread‑Safety Problems, and Practical Solutions
Java Backend Technology
Java Backend Technology
Mar 28, 2021 · Backend Development

Hidden Java Memory Leaks: 8 Common Pitfalls and How to Fix Them

This article explains eight typical Java memory‑leak scenarios—including unclosed resources, missing equals/hashCode, non‑static inner classes, overridden finalize, String.intern misuse, ThreadLocal traps, and static variables in web containers—provides code examples for each, and offers practical mitigation strategies.

Garbage CollectionJavaThreadLocal
0 likes · 11 min read
Hidden Java Memory Leaks: 8 Common Pitfalls and How to Fix Them
Top Architect
Top Architect
Feb 10, 2021 · Backend Development

Understanding Thread Safety Issues in Java ArrayList and How to Fix Them

This article explains why Java's ArrayList is not thread‑safe, illustrates the two main concurrency problems—array index out‑of‑bounds and element overwriting—through source‑code analysis and multithreaded examples, and presents several practical solutions such as synchronized wrappers, explicit locking, CopyOnWriteArrayList and ThreadLocal.

ArrayListCollectionsCopyOnWriteArrayList
0 likes · 11 min read
Understanding Thread Safety Issues in Java ArrayList and How to Fix Them
FunTester
FunTester
Feb 7, 2021 · Backend Development

Using ThreadLocal for Collect/Uncollect Performance Testing in Java

This article demonstrates how to apply Java's ThreadLocal together with an AtomicInteger to generate unique minisource_id values for a collect‑and‑uncollect workflow, and shows the complete code modifications and performance‑test script used to measure request latency.

BackendJavaThreadLocal
0 likes · 6 min read
Using ThreadLocal for Collect/Uncollect Performance Testing in Java
FunTester
FunTester
Feb 6, 2021 · Fundamentals

Mastering Java ThreadLocal: Achieve Thread‑Safe Objects Without synchronized

This article explains how Java's ThreadLocal class provides a thread‑local storage mechanism that creates independent object instances for each thread, improving scalability and performance compared to synchronized blocks, and demonstrates its usage with practical code examples and best‑practice guidelines.

Backend DevelopmentJavaThreadLocal
0 likes · 8 min read
Mastering Java ThreadLocal: Achieve Thread‑Safe Objects Without synchronized
vivo Internet Technology
vivo Internet Technology
Jan 27, 2021 · Backend Development

TransmittableThreadLocal Practice: Solving Multi-Country Business Context Propagation in E-commerce

The article explains how to reliably propagate country‑specific context across request handling, database access, and asynchronous thread pools in multi‑country e‑commerce by replacing simple ThreadLocal and InheritableThreadLocal with Alibaba’s TransmittableThreadLocal, demonstrating its integration with Spring MVC/Boot, MyBatis, Dubbo, and custom executors for both sharded and non‑sharded databases.

AlibabaInheritableThreadLocalJava concurrency
0 likes · 16 min read
TransmittableThreadLocal Practice: Solving Multi-Country Business Context Propagation in E-commerce
Code Ape Tech Column
Code Ape Tech Column
Dec 27, 2020 · Backend Development

Why ThreadLocal and ConcurrentHashMap Can Still Cause Bugs—and How to Fix Them

This article examines common misconceptions about Java concurrency utilities such as ThreadLocal, ConcurrentHashMap, and CopyOnWriteArrayList, demonstrates real‑world bugs caused by thread reuse and non‑atomic operations, and provides concrete solutions and performance‑tested alternatives.

ConcurrentHashMapCopyOnWriteArrayListJava concurrency
0 likes · 12 min read
Why ThreadLocal and ConcurrentHashMap Can Still Cause Bugs—and How to Fix Them
Selected Java Interview Questions
Selected Java Interview Questions
Dec 26, 2020 · Backend Development

Thread Reuse Pitfalls, ThreadLocal Misuse, and Proper Use of ConcurrentHashMap and CopyOnWriteArrayList

This article explains how thread reuse in a Tomcat thread pool can cause user‑information leakage when ThreadLocal is misused, analyzes the non‑atomic behavior of ConcurrentHashMap operations, demonstrates performance differences between locking and atomic methods, and warns against inappropriate use of CopyOnWriteArrayList in high‑write scenarios.

ConcurrentHashMapCopyOnWriteArrayListJava concurrency
0 likes · 13 min read
Thread Reuse Pitfalls, ThreadLocal Misuse, and Proper Use of ConcurrentHashMap and CopyOnWriteArrayList
vivo Internet Technology
vivo Internet Technology
Oct 22, 2020 · Backend Development

ThreadLocal Context Propagation with Hystrix

The article explains how to propagate ThreadLocal data such as a traceId across Hystrix’s thread‑pool isolation by implementing a custom HystrixConcurrencyStrategy or, more robustly, a HystrixCommandExecutionHook that uses HystrixRequestContext, ensuring the context is correctly transferred even to fallback methods.

ContextPropagationHystrixJava
0 likes · 12 min read
ThreadLocal Context Propagation with Hystrix
Code Ape Tech Column
Code Ape Tech Column
Oct 21, 2020 · Backend Development

Mastering Spring Boot: How to Integrate Multiple Data Sources with MyBatis

This tutorial explains how to configure Spring Boot with a single Druid data source, extend it to multiple dynamic data sources using AbstractRoutingDataSource, and seamlessly integrate MyBatis, including custom annotations, AOP switching, thread‑local isolation, and transaction management for robust multi‑database applications.

Dynamic Data SourceJavaMultiple Data Sources
0 likes · 18 min read
Mastering Spring Boot: How to Integrate Multiple Data Sources with MyBatis
Su San Talks Tech
Su San Talks Tech
Oct 7, 2020 · Backend Development

8 Proven Java Techniques to Ensure Thread‑Safe Data in Concurrent Apps

This article outlines eight practical Java approaches—including stateless design, immutability, safe publication, volatile fields, synchronized blocks, explicit locks, CAS operations, and ThreadLocal—to guarantee data safety in multithreaded environments, explaining each concept and providing concise code examples.

CASLockSynchronization
0 likes · 6 min read
8 Proven Java Techniques to Ensure Thread‑Safe Data in Concurrent Apps
Programmer DD
Programmer DD
Sep 29, 2020 · Backend Development

How ThreadLocal Works Internally and Why It Can Cause Memory Leaks

This article explains the internal mechanism of Java's ThreadLocal, how each thread maintains its own isolated map, why weak references are used for keys, and how improper cleanup in thread‑pool environments can lead to subtle memory‑leak problems.

Backend DevelopmentJavaThreadLocal
0 likes · 6 min read
How ThreadLocal Works Internally and Why It Can Cause Memory Leaks
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Sep 18, 2020 · Backend Development

Optimizing Service Calls with ThreadLocal Cache and Custom Annotations in Java

The article explains how to reduce redundant service calls in Java back‑end systems by passing required data from upper layers, applying cache annotations, and implementing an elegant ThreadLocal‑based caching mechanism using custom annotations, aspects, and filters to improve performance without extensive code changes.

JavaThreadLocalannotations
0 likes · 9 min read
Optimizing Service Calls with ThreadLocal Cache and Custom Annotations in Java
Programmer DD
Programmer DD
Aug 6, 2020 · Fundamentals

Why Overriding equals Without hashCode Can Cause Memory Leaks in Java

This article explores the distinction between OutOfMemory errors and memory leaks in Java, explains how improper use of static fields, unclosed streams, incorrect equals/hashCode implementations, and ThreadLocal can lead to leaks, and provides practical solutions and tools such as JVisualVM to detect and prevent them.

JVMOutOfMemoryThreadLocal
0 likes · 14 min read
Why Overriding equals Without hashCode Can Cause Memory Leaks in Java
Programmer DD
Programmer DD
Jun 29, 2020 · Backend Development

Why Spring Beans Aren’t Thread‑Safe and How ThreadLocal Solves It

This article explains that Spring does not guarantee thread safety for its beans, describes the various bean scopes, clarifies why stateless singleton beans are safe, and shows how ThreadLocal works—including its implementation, usage, and potential memory‑leak pitfalls—so developers can write correct concurrent code.

JavaThreadLocalconcurrency
0 likes · 17 min read
Why Spring Beans Aren’t Thread‑Safe and How ThreadLocal Solves It
Top Architect
Top Architect
Jun 22, 2020 · Information Security

Implementing Token-Based Authentication, Anti‑DoS, and Repeat‑Submission Prevention in Spring Boot

This article explains how to design a secure token mechanism with timestamp validation, describes common DoS attack types, and provides practical Spring Boot code examples—including Redis configuration, token generation, interceptor logic, MD5 signing utilities, and ThreadLocal usage—to prevent repeat submissions and protect APIs.

DoS protectionJavaSpring Boot
0 likes · 21 min read
Implementing Token-Based Authentication, Anti‑DoS, and Repeat‑Submission Prevention in Spring Boot
Java Backend Technology
Java Backend Technology
Jun 18, 2020 · Backend Development

How to Build a Reentrant Distributed Lock with Redis, ThreadLocal, and Lua

This article explains why redoing a system can be simpler than refactoring, then dives into implementing a reentrant distributed lock using Redis with both ThreadLocal and Redis Hash approaches, providing detailed Java code, Lua scripts, and practical tips for handling lock expiration and multi‑process reentrancy.

JavaLuaSpring Boot
0 likes · 17 min read
How to Build a Reentrant Distributed Lock with Redis, ThreadLocal, and Lua
Selected Java Interview Questions
Selected Java Interview Questions
Jun 17, 2020 · Information Security

API Security Practices: Tokens, Timestamps, Signatures, and Anti‑Replay Measures with Java Examples

This article explains common API security mechanisms such as token and user token usage, timestamp validation, signature generation, anti‑replay strategies, DoS attack types, and provides Java Spring Boot code examples for token handling, request interception, custom annotations, and ThreadLocal utilities.

API SecurityDoS protectionJava Spring
0 likes · 22 min read
API Security Practices: Tokens, Timestamps, Signatures, and Anti‑Replay Measures with Java Examples
Java Captain
Java Captain
May 16, 2020 · Fundamentals

Deep Dive into Java ThreadLocal: Data Structure, Hash Algorithm, Cleanup, and Usage

This article provides an in‑depth analysis of Java’s ThreadLocal mechanism, covering its weak‑reference key, internal ThreadLocalMap structure, hash algorithm, collision resolution, cleanup strategies, expansion logic, source code walkthroughs, and practical usage scenarios such as trace‑ID propagation in distributed systems.

Distributed TracingGarbage CollectionJava
0 likes · 27 min read
Deep Dive into Java ThreadLocal: Data Structure, Hash Algorithm, Cleanup, and Usage
Sohu Tech Products
Sohu Tech Products
Apr 22, 2020 · Backend Development

Understanding ThreadLocal in Java: Implementation, Memory‑Leak Risks, and Practical Use Cases

This article explains Java's ThreadLocal mechanism, shows how it provides thread‑confinement without synchronization, analyses its source code—including hash generation, internal ThreadLocalMap structure, set/get operations and resize logic—highlights potential memory‑leak pitfalls, and lists common application scenarios.

Backend DevelopmentJavaThreadLocal
0 likes · 16 min read
Understanding ThreadLocal in Java: Implementation, Memory‑Leak Risks, and Practical Use Cases
Programmer DD
Programmer DD
Apr 22, 2020 · Backend Development

How ThreadLocal Guarantees Thread Isolation and Avoids Memory Leaks in Java

ThreadLocal provides thread‑confined variables in Java, eliminating race conditions without synchronization; this article explains its concept, demonstrates usage with code examples, analyzes the underlying ThreadLocalMap implementation, discusses hash calculations, potential memory‑leak pitfalls, and outlines common application scenarios.

JavaThreadLocalThreadLocalMap
0 likes · 15 min read
How ThreadLocal Guarantees Thread Isolation and Avoids Memory Leaks in Java
FunTester
FunTester
Feb 24, 2020 · Backend Development

Achieving Thread‑Safe Java Performance Tests Without Locks

This article explains why traditional locking harms Java performance‑testing throughput, introduces lock‑free alternatives such as CAS and ThreadLocal, and provides a complete Java demo that shows how each thread can hold its own object to eliminate contention and boost speed.

JavaPerformance TestingThreadLocal
0 likes · 5 min read
Achieving Thread‑Safe Java Performance Tests Without Locks
Architect's Tech Stack
Architect's Tech Stack
Feb 14, 2020 · Backend Development

Understanding ThreadLocal Variables in Java: Implementation, Memory Leak Issues, and Use Cases

This article explains what ThreadLocal variables are, how they are implemented in Java using a per‑thread ThreadLocalMap, discusses potential memory‑leak pitfalls caused by weak keys, and demonstrates common usage scenarios such as per‑thread session storage and making non‑thread‑safe classes like SimpleDateFormat thread‑safe.

ThreadLocalmemory leakthread safety
0 likes · 7 min read
Understanding ThreadLocal Variables in Java: Implementation, Memory Leak Issues, and Use Cases
AI Code to Success
AI Code to Success
Jan 11, 2020 · Mobile Development

Why Does Creating a Handler in a Background Thread Throw an Exception?

This article explains Android's Handler and Looper mechanism, shows why creating a Handler in a non‑Looper thread triggers a RuntimeException, and walks through the relevant source code—including Handler constructors, Looper.myLooper(), ThreadLocal operations, and the required Looper.prepare() call.

ANRAndroidHandler
0 likes · 10 min read
Why Does Creating a Handler in a Background Thread Throw an Exception?
Programmer DD
Programmer DD
Dec 15, 2019 · Backend Development

Java ThreadLocal Deep Dive: Structure, 0x61c88647 Hash Trick & Usage

This article explains the internal architecture of Java's ThreadLocal, including its ThreadLocalMap implementation, the purpose of the special hash code 0x61c88647, collision handling strategies, proper usage patterns in web applications, and precautions for avoiding memory leaks in thread pools.

HashingJavaMemoryLeak
0 likes · 12 min read
Java ThreadLocal Deep Dive: Structure, 0x61c88647 Hash Trick & Usage
Java Backend Technology
Java Backend Technology
Nov 28, 2019 · Backend Development

How to Prevent ThreadLocal Memory Leaks in Java: Causes and Solutions

This article explains why improper use of ThreadLocal can lead to memory leaks in Java, details the underlying weak‑reference mechanism, and provides practical steps—including explicit removal and Spring integration—to safely manage ThreadLocal data and avoid resource exhaustion.

JavaThreadLocalconcurrency
0 likes · 7 min read
How to Prevent ThreadLocal Memory Leaks in Java: Causes and Solutions
Java Architecture Diary
Java Architecture Diary
Nov 2, 2019 · Backend Development

Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the resulting concurrency errors, and presents four practical solutions—including per‑call instantiation, ThreadLocal, Apache FastDateFormat, and Java 8's Instant with DateTimeFormatter—along with JMH benchmark results comparing their performance across JDK 8 and JDK 11.

SimpleDateFormatThreadLocaldateformat
0 likes · 7 min read
Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently
Amap Tech
Amap Tech
Oct 23, 2019 · Fundamentals

Java Programming Techniques: Collections, ThreadLocal, Pair, Enum, Union, and Generics

The article presents a toolbox of practical Java techniques—including using HashSet for fast duplicate detection, HashMap for building hierarchical structures, ThreadLocal for thread‑specific data, Pair and custom holder classes for multiple return values, enum definitions, union‑style classes, and generic and wildcard patterns—to streamline everyday coding tasks.

CollectionsEnumsJava
0 likes · 22 min read
Java Programming Techniques: Collections, ThreadLocal, Pair, Enum, Union, and Generics
Python Crawling & Data Mining
Python Crawling & Data Mining
Oct 21, 2019 · Fundamentals

Why Python Threads Can’t Fully Utilize Multi‑Core CPUs and How to Use Them Effectively

This tutorial explains Python's multithreading model, its advantages and limitations—including the Global Interpreter Lock—demonstrates thread creation with the threading module, shows race conditions and lock usage, compares processes and threads, and discusses when to choose threads, processes, or asynchronous I/O for different workloads.

GILLockPython
0 likes · 17 min read
Why Python Threads Can’t Fully Utilize Multi‑Core CPUs and How to Use Them Effectively
Tech Musings
Tech Musings
Oct 20, 2019 · Backend Development

How Netty Supercharges ThreadLocal with FastThreadLocal – Inside the Code

This article dissects Netty's custom FastThreadLocal and FastThreadLocalThread implementations, showing how they replace JDK ThreadLocal with constant‑time indexed access, padding to avoid false sharing, and customizable initialization and cleanup to boost backend concurrency performance.

FastThreadLocalNettyThreadLocal
0 likes · 16 min read
How Netty Supercharges ThreadLocal with FastThreadLocal – Inside the Code
Programmer DD
Programmer DD
Sep 5, 2019 · Fundamentals

Understanding ThreadLocal: Solving Thread Safety Issues in Java

This article explains thread safety problems, demonstrates how unsynchronized access to shared variables can produce incorrect results, and shows how Java's ThreadLocal and InheritableThreadLocal classes provide thread‑local storage to avoid concurrency bugs, including implementation details and usage examples.

InheritableThreadLocalJavaThreadLocal
0 likes · 9 min read
Understanding ThreadLocal: Solving Thread Safety Issues in Java
Java Backend Technology
Java Backend Technology
Jul 26, 2019 · Backend Development

Mastering ThreadLocal: When, How, and Best Practices in Java

This article explains the purpose and usage scenarios of Java's ThreadLocal, details its two main functions for storing thread context and ensuring thread safety, discusses garbage‑collection nuances, presents sample code with results, and outlines essential best‑practice guidelines for safe multithreaded development.

JavaThreadLocalconcurrency
0 likes · 8 min read
Mastering ThreadLocal: When, How, and Best Practices in Java
dbaplus Community
dbaplus Community
Jun 16, 2019 · Fundamentals

Understanding Thread Safety: From ThreadLocal to Locks and CAS

This article explains why thread safety concerns memory rather than threads, compares stack‑local and heap‑shared data, introduces ThreadLocal for per‑thread isolation, and covers mutual‑exclusion locks, optimistic CAS, and their appropriate use cases in concurrent programming.

CASJava concurrencyLocks
0 likes · 15 min read
Understanding Thread Safety: From ThreadLocal to Locks and CAS
Programmer DD
Programmer DD
May 12, 2019 · Backend Development

Why SimpleDateFormat Breaks in Multithreaded Java and How to Fix It

This article explains why the classic Java SimpleDateFormat class is not thread‑safe, demonstrates the problems caused by using a static instance in concurrent code, and presents four practical solutions—including creating new instances, synchronizing, using ThreadLocal, and switching to the immutable DateTimeFormatter.

DateTimeFormatterJavaSimpleDateFormat
0 likes · 8 min read
Why SimpleDateFormat Breaks in Multithreaded Java and How to Fix It
Java Backend Technology
Java Backend Technology
Mar 19, 2019 · Backend Development

Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It in Java

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the problems caused by using a static instance in multithreaded code, and presents four practical solutions—including synchronized blocks, ThreadLocal, and the modern DateTimeFormatter—to ensure correct date handling.

DateTimeFormatterJavaSimpleDateFormat
0 likes · 5 min read
Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It in Java
Programmer DD
Programmer DD
Nov 13, 2018 · Backend Development

How to Detect and Prevent Java Memory Leaks: Real‑World Examples and Fixes

This tutorial explains what Java memory leaks are, why they occur, and how to identify them at runtime, covering common leak sources such as static fields, unclosed resources, faulty equals/hashCode implementations, inner classes, finalize methods, string interning, and ThreadLocal misuse, plus practical prevention techniques and profiling tools.

Garbage CollectionJavaProfiling
0 likes · 15 min read
How to Detect and Prevent Java Memory Leaks: Real‑World Examples and Fixes
转转QA
转转QA
Sep 20, 2018 · Backend Development

Implementing Dynamic RPC Service Invocation in a Commercial Testing Platform

The article describes how a commercial testing platform faced three limitations with its RPC client, analyzes Java class‑loading, dynamic proxy, and ThreadLocal concepts, and presents two implementation approaches—one using dynamic proxies and another leveraging ThreadLocal—to enable dynamic loading of multiple rpc.config files without restarting the service.

Dynamic ProxyRPCThreadLocal
0 likes · 6 min read
Implementing Dynamic RPC Service Invocation in a Commercial Testing Platform