"Peters, Jim" wrote:
>
> You can have the thread wake up every
> minute (or ANY increment of time) to see if it's time to check the DB -
> whatever. The point being is that the servlet is loaded, the thread is
> there as long as the server is up, the program can do what you need.
>
Starting threads in servlets is problematic. The issue
is that the servlet container may destroy and recreate
the servlet multiple times over the lifetime of the
container. For example, if no request comes in for a couple
of hours, the container may deactivate the servlet until
the next request comes in.
You're assuming that the thread just keeps running in the
background, but a well-behaved servlet releases all it's
resources in destroy(). If the servlet doesn't release the
resources on it's own, the servlet container can force the
issue (by sending thread interrupts, or using the security
manager to starve the thread's resources, etc)
So you can't assume that any threads created by a servlet
will stick around after the container destroy()'s the
servlet.
For more details and some options:
<URL:http://www.distributopia.com/servlet_stuff/background_threads.txt>
--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com
___________________________________________________________________________
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