This commit is contained in:
lxyer 2018-12-06 20:02:42 +08:00
parent 220ff0a3b0
commit 52ade85767
4 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,8 @@ public abstract class AbstractTask implements Task {
protected String name;
private long theTime;
private Scheduled scheduled;
private boolean isComplete;
private long startTime = System.currentTimeMillis();
public AbstractTask(String name, Scheduled scheduled) {
this.name = name;
@ -45,5 +47,18 @@ public abstract class AbstractTask implements Task {
this.theTime = next.toInstant(ZoneOffset.of("+8")).toEpochMilli();
return theTime;
}
@Override
public boolean isComplete() {
return isComplete;
}
public void setComplete(boolean complete) {
isComplete = complete;
}
public long startTime() {
return startTime;
}
}

View File

@ -38,4 +38,16 @@ public interface Task extends Runnable{
* 执行任务
*/
void run();
/**
* 是否完成
* @return
*/
boolean isComplete();
/**
* 开始时间创建时间
* @return
*/
long startTime();
}

View File

@ -44,6 +44,7 @@ public class TimerExecutor {
e.printStackTrace();
}
//执行调度
executor.execute(take);
add(take, true);
}catch (Exception e){

View File

@ -22,4 +22,9 @@ public class TaskImpl extends AbstractTask {
}
System.out.printf("执行任务:%s now:%s, %n", name, sdf.format(System.currentTimeMillis()));
}
@Override
public long startTime() {
return 0;
}
}