Hi,
Tomcat reuses request processing threads across webapps: the thread pool
is associated with a connector, and all apps served by that connector
will use this pool.

The Servlet Spec guarantees you that one thread will serve the entire
request from start to finish, i.e. any filters, servlets, includes, etc
will be processed by the same thread.  Needless to say, tomcat obeys
this.  Other than that, the spec leaves thread management and allocation
up to the container implementation, with the terrible exception that's
now thankfully removed of SingleThreadModel.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Greg Ward [mailto:[EMAIL PROTECTED]
>Sent: Monday, June 07, 2004 3:20 PM
>To: [EMAIL PROTECTED]
>Subject: Thread reuse question (Tomcat 4.1)
>
>I have a question motivated by our application's slightly peculiar
>logging requirements.  (Details below, if you're curious.)
>
>Specifically, does Tomcat 4.1 reuse request-processing threads across
>web apps, or only within a single web app?  I.e. if thread X is created
>to service a request for web app #1, will that thread ever be used to
>service requests for any other web app?  Or is it exclusively devoted
to
>the use of web app #1?
>
>Rationale: we'd like our web apps to have per-user log files; this is
>for a moderate-traffic, high-log-output family of applications, so
>separating the log output by user makes sense.  The obvious way to do
>that is have a thread-local log object that is initialized when
starting
>a request, and closed when finishing the request.
>
>The catch: what state do I leave the ThreadLocal in when finishing each
>request?  Right now, I'm pointing it to the default log file for the
>current web app, eg. app1.log.  But if the thread that just processed a
>request for web app #1 is reused for web app #2, and web app #2 does
not
>set the thread-local log object correctly, things will get confusing --
>some libraries used by web app #2 in processing the request will log to
>the thread-local log object, namely app1.log.
>
>So at the very least, I'd like to know how Tomcat 4.1 reuses threads.
>Better yet, I'd like to know if the servlet spec makes any guarantees
in
>this are -- I've read what I think are the relevant sections (2.2,
2.3),
>but I didn't see anything.
>
>Thanks --
>
>        Greg
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to