Tag

threadlocal

1 views collected around this technical thread.

Lobster Programming
Lobster Programming
Jun 3, 2025 · Backend Development

How ThreadLocal Can Cause Memory Leaks in Java Multithreading

This article explains how ThreadLocal creates per‑thread variable copies, demonstrates its usage with sample Java code, illustrates the internal storage structure, and reveals why improper handling can lead to memory leaks when thread‑local values persist in thread pools.

JavaMemory Leakconcurrency
0 likes · 3 min read
How ThreadLocal Can Cause Memory Leaks in Java Multithreading
Top Architecture Tech Stack
Top Architecture Tech Stack
May 15, 2025 · Backend Development

Understanding Cookie + Session Mechanism and Distributed Session Sharing Solutions

This article explains the Cookie + Session mechanism for maintaining user state, discusses its limitations such as size, performance and security, examines challenges in distributed environments, and reviews common solutions including session replication, sticky load balancing, centralized storage, and the use of ThreadLocal for small‑scale backend applications.

Distributed SystemsWeb Developmentbackend
0 likes · 17 min read
Understanding Cookie + Session Mechanism and Distributed Session Sharing Solutions
Selected Java Interview Questions
Selected Java Interview Questions
May 14, 2025 · Backend Development

Enterprise Java Core Features: Full‑Chain Logging, Unified Exception Handling, Permission Interceptor, and Thread Context Management

This article presents a comprehensive guide to implementing full‑chain log tracing, unified exception handling, permission interception, request latency monitoring, and standardized log formats in enterprise‑level Java projects using Spring AOP, thread‑local context, and Redis caching.

AOPExceptionHandlingJava
0 likes · 23 min read
Enterprise Java Core Features: Full‑Chain Logging, Unified Exception Handling, Permission Interceptor, and Thread Context Management
Cognitive Technology Team
Cognitive Technology Team
May 4, 2025 · Backend Development

Understanding Java ThreadLocal Memory Leaks: Mechanisms, Risks, Diagnosis, and Defensive Practices

This article explains the inner workings of Java's ThreadLocal, analyzes how weak and strong references can cause memory leaks in thread pools, demonstrates typical leak scenarios with code examples, and provides diagnostic tools and defensive coding practices to prevent such leaks.

Garbage CollectionJavaMemory Leak
0 likes · 9 min read
Understanding Java ThreadLocal Memory Leaks: Mechanisms, Risks, Diagnosis, and Defensive Practices
Cognitive Technology Team
Cognitive Technology Team
May 3, 2025 · Fundamentals

Understanding Java ThreadLocalMap: Structure, Operations, and Memory Management

This article explains the internal design of Java's ThreadLocalMap, covering its core Entry structure, hash table storage, linear probing for collision resolution, key operations (set, get, remove), memory‑leak scenarios, automatic cleanup mechanisms, and practical usage patterns such as thread‑context propagation and Android Looper.

JavaMemoryManagementWeakReference
0 likes · 10 min read
Understanding Java ThreadLocalMap: Structure, Operations, and Memory Management
Cognitive Technology Team
Cognitive Technology Team
May 3, 2025 · Backend Development

Understanding ThreadLocal: Core Principles, Use Cases, Pitfalls, and Best Practices

ThreadLocal provides per‑thread variable storage to achieve thread isolation, improving concurrency performance, and is essential for safe data handling in Java, but improper use can cause memory leaks, data contamination, and other issues; this article explains its internal mechanism, common scenarios, pitfalls, and best‑practice guidelines with code examples.

JavaMemory Leakbest practices
0 likes · 19 min read
Understanding ThreadLocal: Core Principles, Use Cases, Pitfalls, and Best Practices
Architect's Tech Stack
Architect's Tech Stack
Apr 11, 2025 · Backend Development

Understanding FastThreadLocal vs ThreadLocal in Java: Implementation and Performance

This article explains the internal workings of Java's ThreadLocal and Netty's FastThreadLocal, compares their memory management and lookup mechanisms, provides code examples, and offers guidance on when to choose each for high‑concurrency backend applications.

JavaNettyconcurrency
0 likes · 7 min read
Understanding FastThreadLocal vs ThreadLocal in Java: Implementation and Performance
Cognitive Technology Team
Cognitive Technology Team
Apr 11, 2025 · Backend Development

Spring AOP Advice Execution Order Changes After Upgrading to Spring Boot 2.7.1

Upgrading to Spring Boot 2.7.1 (Spring Framework 5.3.21) alters the execution order of @Around, @Before, @After, @AfterReturning, and @AfterThrowing advice within the same @Aspect, causing ThreadLocal data loss and prompting a recommendation to consolidate logic into a single @Around advice.

AOPAdvice OrderAspectJ
0 likes · 3 min read
Spring AOP Advice Execution Order Changes After Upgrading to Spring Boot 2.7.1
Selected Java Interview Questions
Selected Java Interview Questions
Apr 10, 2025 · Backend Development

Understanding PageHelper Issues and ThreadLocal Pitfalls in MyBatis

This article analyzes unexpected behaviors caused by PageHelper in a Java backend project, such as duplicate user registration, limited query results, and password‑reset errors, and explains how ThreadLocal pagination parameters, startPage(), and cleanup mechanisms lead to these problems while offering practical debugging tips.

JavaMyBatisPageHelper
0 likes · 11 min read
Understanding PageHelper Issues and ThreadLocal Pitfalls in MyBatis
Selected Java Interview Questions
Selected Java Interview Questions
Mar 13, 2025 · Backend Development

Implementing Dynamic Data Source Switching in Spring Boot with ThreadLocal and AbstractRoutingDataSource

This article demonstrates how to build a dynamic data source switching mechanism in Spring Boot by leveraging ThreadLocal for thread‑scoped context and AbstractRoutingDataSource for routing, covering manual implementation, annotation‑driven switching, and runtime addition of new data sources.

AbstractRoutingDataSourceDynamicDataSourceJava
0 likes · 14 min read
Implementing Dynamic Data Source Switching in Spring Boot with ThreadLocal and AbstractRoutingDataSource
Selected Java Interview Questions
Selected Java Interview Questions
Feb 16, 2025 · Backend Development

Understanding ThreadLocal Implementation and Memory Leak Issues in Java

This article explains how ThreadLocal stores values per thread, details the internal set and get mechanisms, discusses potential memory‑leak problems caused by stale entries, and provides best‑practice guidelines such as using remove() and InheritableThreadLocal for child threads.

InheritableThreadLocalJavaMemoryLeak
0 likes · 9 min read
Understanding ThreadLocal Implementation and Memory Leak Issues in Java
JD Tech Talk
JD Tech Talk
Dec 27, 2024 · Backend Development

Log Sampling and Cross‑Thread Propagation in High‑Throughput Java Services

The article examines the performance impact of excessive logging in large‑scale Java systems and proposes request‑level sampling with cross‑thread identifier propagation, offering practical component‑based solutions, implementation considerations, and a concrete code example for backend developers.

Javabackendlogging
0 likes · 7 min read
Log Sampling and Cross‑Thread Propagation in High‑Throughput Java Services
Code Ape Tech Column
Code Ape Tech Column
Nov 25, 2024 · Backend Development

Elegant Methods for Passing Data Between Parent and Child Threads in Spring Boot

This article explains four techniques—manual setting, TaskDecorator, InheritableThreadLocal, and TransmittableThreadLocal—for propagating context such as user information from a parent thread to child threads in Spring Boot asynchronous execution, providing code examples and recommendations.

AsyncJavaSpring Boot
0 likes · 14 min read
Elegant Methods for Passing Data Between Parent and Child Threads in Spring Boot
Top Architect
Top Architect
Nov 21, 2024 · Backend Development

Best Practices and Common Pitfalls of Using Thread Pools in Java

This article summarizes how to correctly declare, monitor, configure, and name Java thread pools, explains common mistakes such as unbounded queues and ThreadLocal contamination, and introduces dynamic tuning techniques and open‑source solutions for robust backend concurrency management.

JavaSpringBootbest practices
0 likes · 18 min read
Best Practices and Common Pitfalls of Using Thread Pools in Java
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Oct 28, 2024 · Backend Development

Resolving Missing Request Headers in Spring MVC Multithreaded Environments

This article analyzes why Spring MVC fails to retrieve request header fields in multithreaded scenarios, explains the underlying ThreadLocal storage mechanism, critiques a common but flawed solution, and presents reliable approaches using CountDownLatch, manual RequestContextHolder propagation, and request caching to ensure header availability across threads.

JavaRequestContextHolderSpring MVC
0 likes · 10 min read
Resolving Missing Request Headers in Spring MVC Multithreaded Environments
Architect's Guide
Architect's Guide
Sep 18, 2024 · Backend Development

Understanding Cookie+Session, Distributed Session Sharing, and ThreadLocal for Maintaining User Login State

This article explains the limitations of traditional Cookie+Session authentication, explores distributed session sharing techniques such as replication, sticky sessions, and centralized storage, and demonstrates why using ThreadLocal can simplify user state management in a web application like the Echo project.

Distributed SystemsSession Managementbackend
0 likes · 9 min read
Understanding Cookie+Session, Distributed Session Sharing, and ThreadLocal for Maintaining User Login State
Architect's Guide
Architect's Guide
Sep 6, 2024 · Backend Development

Implementing Dynamic Data Source Switching in Spring Boot with ThreadLocal and AbstractRoutingDataSource

This article demonstrates how to implement dynamic data source switching in a Spring Boot application by leveraging ThreadLocal and AbstractRoutingDataSource, providing step‑by‑step code examples for context holders, custom routing, annotation‑driven switching, and runtime addition of new data sources.

AOPAbstractRoutingDataSourceDynamicDataSource
0 likes · 14 min read
Implementing Dynamic Data Source Switching in Spring Boot with ThreadLocal and AbstractRoutingDataSource
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Aug 15, 2024 · Backend Development

Master SpringBoot Interceptors to Avoid OOM: Proper postHandle and afterCompletion Strategies

This article explains how SpringBoot interceptors work, demonstrates custom interceptor implementation, shows how misuse of ThreadLocal can cause memory leaks and OOM errors, and provides a fix by moving cleanup logic to afterCompletion, complete with code samples and performance screenshots.

InterceptorJavaOOM
0 likes · 9 min read
Master SpringBoot Interceptors to Avoid OOM: Proper postHandle and afterCompletion Strategies
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Aug 14, 2024 · Backend Development

How to Safely Pass ThreadLocal Values Across Thread Pools with TTL

This article explains the limitations of Java's ThreadLocal and InheritableThreadLocal in thread‑pool scenarios, introduces Alibaba's open‑source TransmittableThreadLocal (TTL) library, and provides detailed code examples for safely transmitting thread‑local data across threads, thread pools, and even via Java agents.

JavaTTLTransmittableThreadLocal
0 likes · 10 min read
How to Safely Pass ThreadLocal Values Across Thread Pools with TTL