tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riaan Oberholzer <riaanoberhol...@yahoo.com>
Subject Re: [Q] Is it safe to create threads in Tomcat web-apps?
Date Mon, 28 Jul 2003 11:02:04 GMT
Well, that was part of my question.... if I
cannot/don't implement daemon threads to do e.g.
automatic daily tasks, what else? E.g, at the end of
the day send an e-mail to a (real life) manager with a
summary of the day's transactions.... something like
that.

Does Tomcat provide some sort of ActionEvent which you
can configure to be fired every x milliseconds?



--- Tim Funk <funkman@joedog.org> wrote:
> You can create threads all day in tomcat, but here
> are the importnatn things 
> to consider:
> - WHY! Are threads really the correct solution?
> - If you create threads - what are their scope?
> Daemon, non-daemon?
> - If you create non-daemon threads - be prepared for
> the consequences such as 
> the JVM not going away on tomcat shutdown unless you
> have taken the needed 
> precautions.
> - If you create dameon only threads, be prepared for
> when tomcat shuts down 
> and your daemon still has work to do because the JVM
> could exit before your 
> thread is ready to complete its unit of work
> - WHY! Are threads really the correct solution?
> - And last but not least: WHY! Are threads really
> the correct solution?
> 
> -Tim
> 
> Riaan Oberholzer wrote:
> > 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
> > them.
> > 
> > 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
> > web.xml.
> > 
> > How else can you implement that (monitoring) in
> > Tomcat?
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
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