"Caldarale, Charles R" <chuck.caldar...@unisys.com> wrote in message
news:99c8b2929b39c24493377ac7a121e21f96cb817...@usea-exch8.na.uis.unisys.com...
From: Bharath Vasudevan [mailto:bharath....@gmail.com]
Subject: Re: Tomcat threads
If we get a request on a thread, let some other thread do
the work for it and store the response info. The thread
which does the work writes the response on that request.
If the processing is fast, why would you go to the complexity and overhead
of switching to another thread to process the request?
You should also read the servlet spec, in particular SRV.2.3.3.3:
"Implementations of the request and response objects are not guaranteed to
be thread
safe. This means that they should only be used within the scope of the
request handling
thread.
"References to the request and response objects should not be given to
objects
executing in other threads as the resulting behavior may be
nondeterministic. If
the thread created by the application uses the container-managed objects,
such as
the request or response object, those objects must be accessed only within
the
servlet's service life cycle and such thread itself should have a life
cycle within
the life cycle of the servlet's service method because accessing those
objects
after the service method ends may cause undeterministic problems."
The illogical behavior you're asking for simply isn't allowed.
At least not until Tomcat 7 ;). In there, you can do exactly what the user
is asking for using the AsyncContext. The details are in the Servlet 3.0
spec, but basically the request is handed off to another thread and the
original one returns to the pool. This also allows for two-way
communication instead of relying on polling.
Of course Comet offers similar functionality in Tomcat 6 if you don't mind
being bound to Tomcat.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org