add ProxySelector

This commit is contained in:
Looly
2024-11-29 17:21:08 +08:00
parent 5b129a1a8f
commit c2ea26e40d
19 changed files with 252 additions and 156 deletions

View File

@@ -105,17 +105,6 @@ public class CronUtil {
return id;
}
/**
* 加入定时任务
*
* @param schedulingPattern 定时任务执行时间的crontab表达式
* @param task 任务
* @return 定时任务ID
*/
public static String schedule(final String schedulingPattern, final Runnable task) {
return scheduler.schedule(schedulingPattern, task);
}
/**
* 批量加入配置文件中的定时任务
*

View File

@@ -238,17 +238,6 @@ public class Scheduler implements Serializable {
return this;
}
/**
* 新增Task使用随机UUID
*
* @param pattern {@link CronPattern}对应的String表达式
* @param task {@link Runnable}
* @return ID
*/
public String schedule(final String pattern, final Runnable task) {
return schedule(pattern, new RunnableTask(task));
}
/**
* 新增Task使用随机UUID
*

View File

@@ -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.");
}
}

View File

@@ -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);

View File

@@ -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();
}
}

View File

@@ -0,0 +1,5 @@
/**
* 定时任务示例
*
*/
package org.dromara.hutool.cron.demo;