On Tue, Sep 2, 2014 at 3:00 PM, Leon Rosenberg <rosenberg.l...@gmail.com> wrote:
> From practical point of view ThreadLocal is a huge hashmap directly in the > ThreadClass where you can store a map of variables. > Something like Thread.Map<ThreadId, Map<String, Object>>, in which you can > access variables that are 'attached' logically to the current Thread. > In practice its a nice way to pass information through layers of code > without adding it explicitly as parameter to every function on the way. > regards > Leon > At some point in the web application, a ThreadLocal is instantiated and its properties are set and then retrieved in a Filter. Am I on track here? How is that different or more helpful than instantiating any other POJO with property setters? A POJO will be instantiated on every servlet request whereas the ThreadLocal is only created once?