public class Remindtask extends timertask{
private static final int c_schedule_hour = 15;
private static Boolean isrunning = false;
Public Remindtask () {
}
public void Run () {
Calendar cal = Calendar.getinstance ();
if (!isrunning) {
if (C_schedule_hour = = Cal.get (calendar.hour_of_day)) {
IsRunning = true;
System.out.println (New Java.util.Date () + "task start");
TODO for example
int i = 0;
while (i++ < 10) {
System.out.println (New Java.util.Date () + "Done!task" + i + "/" + 10);
}
IsRunning = false;
System.out.println (New Java.util.Date () + "all Task done!");
}
}
Else
{
System.out.println (New Java.util.Date () + "Task existed!");
}
}
}
3.loadonstart in Web.xml
<listener>
<listener-class>timer. Remindlistener</listener-class>
</listener>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.