tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riaan Oberholzer <>
Subject [Q] Is it safe to create threads in Tomcat web-apps?
Date Mon, 28 Jul 2003 07:12:00 GMT
I've mainly worked in BEA WebLogic before and from
colleagues and other sources I have heard it is not
recommended (and sometimes not allowed, some even
said) to create threads in your application. Indeed,
when the application went live in a multi-server
clustered environment, we got very inconsistent
results because of the threads, so we had to remove

Question is, how safe is it to create threads in a
Tomcat web-app? I would assume "worker" threads are
ok, i.e. threads you create to do a specific task and
then it terminates. When you are guaranteed the thread
will terminate either because of an error or because
the assigned task has been completed.

But what about "monitor" threads, i.e. threads that
does a Thread.sleep(x) for an hour, check some
condition and goes back to sleep... some mechanism you
implement to e.g. do a task on a hourly/daily/weekly
base. You'd create the thread (and keep a handle to
it) in either an InitServlet.init() and then
Thread.interrupt() in the InitServlet.destroy(), or
you can do it in an ApplicationListener (something
like that) class which I think you can define in the

How else can you implement that (monitoring) in

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message