package testwrqpper1.wrapper1;java
import java.util.Timer;
import java.util.TimerTask;apache
import org.apache.log4j.Logger;app
/**
* @author lct E-mail:
* @version 建立時間:2018年4月24日 下午3:16:22
* 類說明
*
*/測試
public class TestWrapper1 {
private static Logger logger = Logger.getLogger(TestWrapper1.class);
public static void main(String[] args) {
/**
* public void schedule(TimerTask task, long delay, long period)
* @param task task to be scheduled.
*@param delay delay in milliseconds before task is to be executed.
* @param period time in milliseconds between successive task executions.
*/
Timer timer = new Timer();
//下面這個測試用例,啓動後3秒開始執行,執行成功完成後,再隔5秒再次啓動程序執行test2任務。
timer.schedule(new TimerTask(){
public void run(){
test2();
}
}, 3000, 5000);
logger.info("執行完成...");
}
public static void test2(){
for(int i=0;i<=10;i++){
logger.info("test2 "+i);
}
}
}
.net