tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Tomcat thread model
Date Thu, 17 Dec 2009 20:14:49 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ake,

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksqkTkACgkQ9CaO5/Lv0PBBTACghDgitJwtrDVgoC+1JL2f5xdn
kiEAn2TMRgc88jBJEVyyAjLFcrLyOP6s
=TL0t
-----END PGP SIGNATURE-----

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


Mime
View raw message