Usage of ThreadLocal : per-thread Singleton and per-thread Logging Should you require a refresh of what ThreadLocal s in Java are and how they work, refer to this article first. You can then proceed with the current article for understanding two of the most common uses of ThreadLocal s in Java. per-thread Singleton impl using ThreadLocal Suppose you have a need of having a JDBC Connection objects per thread of your application. The moment you hear the term 'per-thread', ThreadLocal automatically comes into mind as that's what it's primarily meant for. Below is a sample implementation of how easily can you actually use ThreadLocal for a per-thread JDBC Connection object in Java.
About Java and it's related concepts..