tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leo Donahue <>
Subject Re: Question on Thread Local
Date Tue, 02 Sep 2014 20:22:51 GMT
On Tue, Sep 2, 2014 at 3:00 PM, Leon Rosenberg <>

> 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?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message