可以用quartz,或 Timer 定时器的使用
package test;
import java.util.Timer;
public class TimeTaskTest {
public static void main(String[] args){
Timer timer = new Timer();
timer.schedule(new Task(), 10 * 1000);
}
}
package test;
import java.util.TimerTask;
public class Task extends TimerTask {
public void run()
{
System.out.println("定时任务执行");
}
}