📄 taskrunner.java
字号:
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group. All rights reserved. * */package org.redsoft.forum.schedule;import java.util.Timer;import java.util.TimerTask;/** * TimerTask runner */public class TaskRunner { public static final int INTERVAL_SECOND = 1000; public static final int INTERVAL_MINUTE = 60*1000; public static final int INTERVAL_HOUR = 60*60*1000; public static final int INTERVAL_DAY = 60*60*60*1000; // default interval is one minute protected int defalutInterval = INTERVAL_MINUTE * 1; Timer timer = new Timer(); public TaskRunner() { } /** * Schedule a task, let it run every a few minutes * @param task */ public void addTask( TimerTask task ) { addTask( task, defalutInterval ); } /** * Schedule a task, let it run every a few minutes * @param task the task * @param interval milliseconds between each taskes */ public void addTask( TimerTask task, int interval ) { timer.schedule( task, 0, interval ); System.out.println(task + " scheduled "); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -