that is a good point, i think a call back type of mechanism (e.g. destroy()
or
informTermination() ) would be usefull. As it is not rare to come across a
situation
where doGet() can get very long and by that time the user has lost interest
gone
on to something else (which by the way the can have the same behavior). So
eventually
the web-server would be running these useless threads and eat up all the CPU
cycles.
The effect would be very similar to that of a denial-of-service attack.
Subrata
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Kevin
Mukhar
Sent: Monday, June 18, 2001 11:58 AM
To: [EMAIL PROTECTED]
Subject: Re: long doGet()
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
___________________________________________________________________________
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