feat: There is no way the, 动态定时任务
This commit is contained in:
@@ -29,10 +29,10 @@ import java.util.concurrent.ScheduledFuture;
|
||||
public class SchedulerConf {
|
||||
|
||||
//数据库的任务
|
||||
public static ConcurrentHashMap<String, TbTask> tasks = new ConcurrentHashMap<>(10);
|
||||
public static ConcurrentHashMap<String, TbTask> tasks = new ConcurrentHashMap<>(50);
|
||||
|
||||
//正在运行的任务
|
||||
public static ConcurrentHashMap<String, ScheduledFuture> runTasks = new ConcurrentHashMap<>(10);
|
||||
public static ConcurrentHashMap<String, ScheduledFuture> runTasks = new ConcurrentHashMap<>(50);
|
||||
|
||||
//线程池任务调度
|
||||
private ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||
@@ -48,7 +48,7 @@ public class SchedulerConf {
|
||||
*/
|
||||
@Autowired
|
||||
public SchedulerConf(){
|
||||
this.threadPoolTaskScheduler.setPoolSize(10);
|
||||
this.threadPoolTaskScheduler.setPoolSize(50);
|
||||
this.threadPoolTaskScheduler.setThreadNamePrefix("task-thread-");
|
||||
this.threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
|
||||
this.threadPoolTaskScheduler.initialize();
|
||||
@@ -69,10 +69,9 @@ public class SchedulerConf {
|
||||
*/
|
||||
public void start(String taskId){
|
||||
try {
|
||||
//如果为空,重新获取
|
||||
if(SchedulerConf.tasks.size() <= 0){
|
||||
this.getAllTbTask();
|
||||
}
|
||||
//重新获取最新执行任务周期
|
||||
this.getAllTbTask();
|
||||
|
||||
TbTask tbTask = SchedulerConf.tasks.get(taskId);
|
||||
|
||||
//获取并实例化Runnable任务类
|
||||
|
||||
Reference in New Issue
Block a user