Java-util-timertask-scheduledexecutiontime
提供:Dev Guides
java.util.TimerTask.scheduledExecutionTime()メソッド
説明
- scheduledExecutionTime()*メソッドは、このタスクの最新の実際の実行のスケジュールされた実行時間を返すために使用されます。
宣言
以下は* java.util.TimerTask.scheduledExecutionTime()*メソッドの宣言です。
public long scheduledExecutionTime()
パラメーター
NA
戻り値
メソッド呼び出しは、このタスクの最新の実行がスケジュールされた時刻を返します。
例外
NA
例
次の例は、java.util.TimerTask.scheduledExecutionTime()の使用方法を示しています
package com.finddevguides;
import java.util.*;
public class TimerTaskDemo {
public static void main(String[] args) {
//creating timer task, timer
TimerTask task = new TimerTaskCancel();
Timer timer = new Timer();
//scheduling the task
timer.scheduleAtFixedRate(task, new Date(), 1000);
//checking scheduled execution time
System.out.println("Time is :"+task.scheduledExecutionTime());
}
//this method performs the task
public void run() {
System.out.println("Working on the task assigned");
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます。
Time is :1335444782599
Working
Working
Working
Working
Working
Working and so on