mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add ProxySelector
This commit is contained in:
@@ -26,12 +26,12 @@ public class AddAndRemoveMainTest {
|
||||
CronUtil.setMatchSecond(true);
|
||||
CronUtil.start(false);
|
||||
CronUtil.getScheduler().clear();
|
||||
final String id = CronUtil.schedule("*/2 * * * * *", (Runnable) () -> Console.log("task running : 2s"));
|
||||
final String id = CronUtil.schedule("*/2 * * * * *", () -> Console.log("task running : 2s"));
|
||||
ThreadUtil.sleep(3000);
|
||||
CronUtil.remove(id);
|
||||
Console.log("Task Removed");
|
||||
|
||||
CronUtil.schedule("*/3 * * * * *", (Runnable) () -> Console.log("New task add running : 3s"));
|
||||
CronUtil.schedule("*/3 * * * * *", () -> Console.log("New task add running : 3s"));
|
||||
Console.log("New Task added.");
|
||||
}
|
||||
}
|
||||
|
@@ -86,7 +86,8 @@ public class CronTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void addAndRemoveTest() {
|
||||
final String id = CronUtil.schedule("*/2 * * * * *", (Runnable) () -> Console.log("task running : 2s"));
|
||||
final String id = CronUtil.schedule("*/2 * * * * *",
|
||||
() -> Console.log("task running : 2s"));
|
||||
|
||||
Console.log(id);
|
||||
CronUtil.remove(id);
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package org.dromara.hutool.cron.demo;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.cron.CronUtil;
|
||||
|
||||
public class SimpleDemo {
|
||||
public static void main(String[] args) {
|
||||
// 打开秒匹配
|
||||
CronUtil.setMatchSecond(true);
|
||||
// 添加任务
|
||||
CronUtil.schedule("*/2 * * * * *",
|
||||
() -> Console.log("Hutool task running!"));
|
||||
// 启动
|
||||
CronUtil.start();
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* 定时任务示例
|
||||
*
|
||||
*/
|
||||
package org.dromara.hutool.cron.demo;
|
Reference in New Issue
Block a user