When to use ThreadLocal?

JDK 1.2 introduced ThreadLocal class to maintain the thread’s local state. A thread may need to share some state with the classes in which it runs and a thread may have its own local state. To maintain such state in the thread-scope, ThreadLocal can be used instead of declaring the state in the Thread class and using synchronization to share it.

Topics: Context Object Java Tomcat JBoss Multithreading ThreadLocal InheritableThreadLocal memory leak Technology

e-Zest Solutions is digital experience engineering company with facilities in the United States (Detroit & San Jose), Germany (Hannover), United Kingdom (London UK) and India (Pune) with global clientele. Our services include custom software development, offshore software development, UX consulting, BigData, Managed cloud Services (Azure & AWS), SharePoint consulting/Migration, Enterprise Java application development, Automated software testing services.