开发者

Want to send mail after specific time in Java

开发者 https://www.devze.com 2023-01-05 18:17 出处:网络
I want to send mail after specific time Actually I want to send mail after 23 hour from the specific date

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消