Subrata Goswami wrote:
>
> I would think the servlet runner should know when a http connection has been
> torn down and kill the doGet() thread that is just wasting cpu cycles.
Yes, the servlet container does "know" when the connection is closed.
Unfortunately, this knowledge is not gained until some code attempts to do
something with the connection. That usually occurs when the servlet attempts
to write to the output stream. When the servlet writes to the output stream
and the connection has been closed by the client, an IOException is thrown.
The servlet spec does not specify a means for early termination of a thread.
For that reason, there is no safe way for the servlet container to kill a
thread running in a servlet. Further, the spec specifically states that before
the container can call the destroy method it must allow the running threads to
terminate or time-out (Spec 2.3, section 2.3.4). This implies to me that a
container is not allowed to arbitrarily terminate a thread.
One good reason for this is that you don't want the container terminating a
thread that might be in the middle of some transaction. This could leave the
transaction in an incomplete state, and corrupt your system.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html