mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
change cron
This commit is contained in:
@@ -22,6 +22,9 @@ public class CronTest {
|
||||
// 支持秒级别定时任务
|
||||
CronUtil.setMatchSecond(true);
|
||||
CronUtil.start();
|
||||
|
||||
ThreadUtil.waitForDie();
|
||||
Console.log("Exit.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -32,27 +35,27 @@ public class CronTest {
|
||||
CronUtil.getScheduler().setDaemon(false);
|
||||
CronUtil.start();
|
||||
|
||||
ThreadUtil.sleep(3000);
|
||||
ThreadUtil.waitForDie();
|
||||
CronUtil.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void cronTest2() {
|
||||
public void cronWithListenerTest() {
|
||||
CronUtil.getScheduler().addListener(new TaskListener() {
|
||||
@Override
|
||||
public void onStart(TaskExecutor executor) {
|
||||
Console.log("Listen task start!");
|
||||
Console.log("Found task:[{}] start!", executor.getCronTask().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSucceeded(TaskExecutor executor) {
|
||||
|
||||
Console.log("Found task:[{}] success!", executor.getCronTask().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(TaskExecutor executor, Throwable exception) {
|
||||
|
||||
Console.error("Found task:[{}] failed!", executor.getCronTask().getId());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,7 +68,7 @@ public class CronTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Ignore
|
||||
@Ignore
|
||||
public void addAndRemoveTest() {
|
||||
String id = CronUtil.schedule("*/2 * * * * *", (Runnable) () -> Console.log("task running : 2s"));
|
||||
|
||||
|
Reference in New Issue
Block a user