On Mon, November 5, 2007 11:17 am, Ashish Kulkarni wrote:
> Hi
> I dont need more then one thread, or a timer job i would say, this timer
> should sleep and then activate like after 10 minutes, check the database,
> if
> there is nothing to do go back to sleep.
> I will look into quartz, is it ok to use Java Timer and TimerTask to do
> it.

Although I can't say I've ever done it that way, I don't see why it would
be any worse than a straight Thread approach... it might even be better
because the JVM might have a little more control over its management and
can possibly cooperate with the container a little better, but I don't
know that for sure (I also wouldn't be one bit surprised if Timers in Java
are just a thin abstraction around a Thread anyway).

> I will make sure that the class with does check database function will not
> go in loop or be there for ever

You'll also *probabyly* want to get your DB connection the same way as any
app code, which I presume is a JNDI lookup.  At least that way you get
some of that benefit in term of management, but there is a prime example
of making sure that thread code doesn't do anything unsavory... it'd be a
real shame to somehow keep that connection from being returned to the pool
and then find the thread continues to fine and eat a connection each time
:) (I've had this debate with some folks and there's also the thought that
NOT using the same conn pool as the container is actually better because
then the pool can't be exhausted... then again, at that point you run the
risk of chewing up the listener threads in the RDBMS, so six of one, half
dozen of another I figure).

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to