tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron <>
Subject Tomcat, Timer and TimerTask question
Date Thu, 20 Jul 2006 03:52:38 GMT

Just trying to schedule a batch email run using Timer and TimerTask framework on
Tomcat 4.1.31

Found the following example from

Trying trying to test this scheduling mechanism first just by printing to
System.out first... (see below) 

It does not seem to run. Code compiles properly in eclipse.

Does tomcat require any libraries... There is no errors in tomcat either.

public final class schedEmailUser extends TimerTask {

	public static void main (String[] args) {
	    TimerTask schedEmail  = new schedEmailUser();

	    Timer timer = new Timer();
	    Calendar date = Calendar.getInstance();
	    date.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
	    date.set(Calendar.HOUR, 12);
	    date.set(Calendar.MINUTE, 10);
	    date.set(Calendar.SECOND, 0);
	    date.set(Calendar.MILLISECOND, 0);
	    timer.scheduleAtFixedRate(new schedEmailUser(), date.getTime(), 1000 * 60 *
60 * 24);
	    System.out.println("In main Sending email...");

        public void run(){
          System.out.println("In run Sending email...");
} //end schedEmailUser

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message