Want to send mail after specific time in Java
I want to send mail after specific time
Actually I want to send mail after 23 hour from the specific date
Now I am using java.util.TimerTask 开发者_JAVA技巧Thread to call that email function
Please help me..
Thanks
The combination of Timer
and TimerTask
should suffice. The Timer
class has a schedule()
method. Just pass the TimerTask
and a Date
representing today plus 23 hours along it.
Timer timer = new Timer(true);
timer.schedule(new MailTask(), todayPlus23hours);
where the MailTask
look like this:
public class MailTask extends TimerTask {
public void run() {
// Implement.
}
}
Have you tried to use something like QuartZ Scheduler which will help manage scheduling and executing tasks: http://www.quartz-scheduler.org/
精彩评论