ThreadLocal : Global container to store Thread's state

The Problem Java Developers of multi threaded application might feel a need to store global variables which should not be shared by multiple threads. Example - Storing user information while handling a web request on multi threaded server. Solution : ThreadLocal ThreadLocal object acts as a variable container which enables you to create and maintain a global state which is tied to one thread. Each thread accessing the ThreadLocal object will have it’s own copy of underlying variable....

October 1, 2018 · Dinesh Sawant