tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat thread model
Date Thu, 17 Dec 2009 20:14:49 GMT
Hash: SHA1


On 12/17/2009 2:17 PM, Ake Tangkananond wrote:
> I am finding a way to keep a variable in a request scope. I feel it is
> cumbersome to put that into request variable and pass it through multiple
> objects. So, I think I will make it accessible through a static class
> variable. I wonder if I can put it into a static ThreadLocal variable in a
> class?

That will work. Just remember to ensure that value is removed after the
request is processed, otherwise you may have a security problem and/or
memory leaks.

> To rephrase the question: Though the thread pooling is possible, and one
> thread may serve multiple requests, can it be guaranteed that each thread
> will serve only a single request at the same time? If the answer is "yes",
> does this apply to all Java Servlet implementation ?

Yes and yes: a single thread cannot execute two code paths at once
(that's kind of the definition of a thread) and all servlet containers
(or all Java programs for that matter) will behave the same way.

If Java ever adds call-cc, maybe that will change :)

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message