tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <Peter.Crowt...@melandra.com>
Subject RE: Is there an easy way to replace http-processor threads?
Date Fri, 21 Jul 2006 10:30:04 GMT
> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com] 
> Now I have the unpleasant
> situation that i need some information pretty deep in some use cases
> of the application (like current locale) which I only have at the top
> (servlet) level.

We had the same issue with an app.  Provided you remember that Tomcat
re-uses threads, this isn't actually that much of a problem if all of
your processing is done on the request's thread.  Simply use a global
class with a ThreadLocal
(http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ThreadLocal.html)
instance variable holding your extra data.  Because of re-use, remember
to nil the variable at the start of your processing, possibly even in a
Filter if you're feeling paranoid.

We took that approach.  I'll be interested to hear of any others.

		- Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message