ScheduledThreadPoolExecutor

String time = new SimpleDateFormat("HH:mm:ss").format(new Date());

System.out.println("Start time : " + time);


ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(

5); // 創建5個執行線程


Runnable runnable = new Runnable() {


@Override

public void run() {

// TODO Auto-generated method stub

String time = new SimpleDateFormat("HH:mm:ss")

.format(new Date());

System.out.println("Now Time : " + time);

}

};


executor.scheduleWithFixedDelay(runnable, 2, 3, TimeUnit.SECONDS);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章