Java · Medium
What is ThreadLocal? When and why should you use it? What are its pitfalls?
JavaCore JavaConcurrency
Answer preview
ThreadLocal — provides per-thread isolated copies of a variable. Each thread accessing the variable via get()/set() works with its own independent copy — no synchronization needed.…