scheduleExecutionTime() 是 TimerTask 类的方法。此方法返回最近执行的任务的给定执行时间。
用法
public long scheduledExecutionTime()
返回
它返回最近执行的任务的执行时间。
例子1
import java.util.*;
public class TimerTaskScheduledExecutionTimeExample1{
public static void main(String[] args) {
// creating timer task, timer
Timer t = new Timer();
TimerTask tt = new TimerTask() {
@Override
public void run() {
for(int i=1; i<=10;i++)
{
System.out.println("Task Timer is on");
}
};
};
t.scheduleAtFixedRate(tt, new Date(), 1000);
System.out.println("Time is:"+tt.scheduledExecutionTime());
}
}
输出:
Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Time is:1533927090455 Task Timer is on Task Timer is on Task Timer is on . . .
例子2
import java.util.*;
public class TimerTaskScheduledExecutionTimeExample2{
public static void main(String[] args) {
// creating timer task, timer
Timer t = new Timer();
TimerTask tt = new TimerTask() {
@Override
public void run() {
System.out.println("Task Timer is on");
};
};
t.scheduleAtFixedRate(tt, new Date(), 1000);
System.out.println("Time is:"+tt.scheduledExecutionTime());
}
}
输出:
Time is:1534099265658 Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on Task Timer is on . .. . . .
相关用法
- Java TimerTask run()用法及代码示例
- Java TimerTask cancel()用法及代码示例
- Java Timer scheduleAtFixedRate()用法及代码示例
- Java Timer purge()用法及代码示例
- Java Timer schedule()用法及代码示例
- Java Timer cancel()用法及代码示例
- Java TimeZone setDefault()用法及代码示例
- Java TimeUnit values()用法及代码示例
- Java TimeZone getDisplayName(boolean, int)用法及代码示例
- Java TimeUnit toSeconds()用法及代码示例
- Java TimeZone observesDaylightTime()用法及代码示例
- Java TimeZone getDisplayName(Locale locale)用法及代码示例
- Java TimeZone getDefault()用法及代码示例
- Java TimeZone useDaylightTime()用法及代码示例
- Java SQL Timestamp before()用法及代码示例
- Java TimeUnit toNanos()用法及代码示例
- Java TimeZone hasSameRules()用法及代码示例
- Java TimeUnit toDays()用法及代码示例
- Java SQL Timestamp getNanos()用法及代码示例
- Java TimeZone setRawOffset()用法及代码示例
注:本文由纯净天空筛选整理自 Java TimerTask scheduledExecutionTime() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。