tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Spawn New Thread
Date Thu, 10 Jun 2004 13:08:49 GMT

Hi,
>Really I nead the thread to be up the lifetime of Tomcat

No, you don't: at most you need the thread to be up for the lifetime of
your webapp.  If you really need it to be up for the lifetime of tomcat,
that's pretty terrible design.

>because I know MyServlet will be loaded when Tomcat is. This seems to
work
>but is kind of "goofy" because the thread does not have a direct
>relationship with the servlet it's just the only place I know to kick
it
>off.  Is there a better (or atleast more natural) place to start this
>thread?

Yes, there is: a ServletContextListener's contextInitialized  method to
start your thread, and contextDestroyed method to close and shutdown
your thread.  These types of things are exactly what
ServletContextListeners were designed for.

Yoav



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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message