Ok, but like I said, all the developers 'round these parts are saying that
threads are a no-no.

Honestly, I'm not even sure that the DB cleanup I'm trying to perform needs
to happen every five minutes.  Honestly, it only needs to happen each time a
new user tries to register or gets added....

hmmmmmm.....

looks like I don't need to do this after all.....

Unless someone has a better, cooler idea......

-----Original Message-----
From: James Courtney [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2003 6:07 PM
To: Ciramella, EJ
Cc: Tomcat Users List
Subject: RE: Running a class on startup - java newbie....


EJ,
        You can create an initialization servlet that get's loaded at
startup of your webapp.  This servlet could create a thread that does what
Andre suggests below.  Use the web.xml to configure any parameters you need
to pass to this servlet and to ensure it's loaded first.  Then just define
an init method for that servlet that creates and executes your thread.  You
can use the servlet's destroy method to shut down your thread.

Jamey


-----Original Message-----
From: Andre D Bonner [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2003 2:55 PM
To: Tomcat Users List
Subject: Re: Running a class on startup - java newbie....


>What I'd like to do is
> have <something> running that sleeps for 5 minutes at a time and then
checks
> to see if 24 hours have passed since the row was inserted (and if so,
delete
> it).  Is there a way to start up a class with my web app?
> 


Looks like good old Thread based timer

It is a thread that sits and calls a method every 5 minutes?

while(true){
Thread.sleep(5 * 60 * 1000) // 5 minutes exactly

  // lookup my jdbc Datasource
 // do my jdbc checking?
  // releaseConnection
  // loop
}


-- 
Andre D Bonner
Sun Certified Programmer for the Java� 2 Platform 1.4



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

Reply via email to