| | |
| | | package com.dy.common.mw.core; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.apache.logging.log4j.*; |
| | |
| | | |
| | | private final static CoreConstantManage instance = new CoreConstantManage() ; |
| | | |
| | | private static Long sleepBigBusy = 100L ;//大忙时(除了恒久任务,还是其他任务),核心线程暂停间隔 |
| | | private static Long sleepSmallBusy = 500L ;//小忙时(只有恒久任务,无其他任务),核心线程暂停间隔 |
| | | |
| | | private List<CoreConstantTimer> coreConstantTimers ; |
| | | |
| | | private Long coreInterval = 100L ;//核心线程暂停间隔 |
| | | |
| | | private CoreConstantManage(){ |
| | | coreConstantTimers = new ArrayList<>() ; |
| | | } |
| | | |
| | | public static CoreConstantManage getInstance(){ |
| | |
| | | |
| | | /** |
| | | * 设置暂停时长 |
| | | * @param sleepBigBusy 大忙时(除了恒久任务,还是其他任务),核心线程暂停间隔 |
| | | * @param sleepSmallBusy 小忙时(只有恒久任务,无其他任务),核心线程暂停间隔 |
| | | * @param coreInterval 核心线程暂停间隔 |
| | | */ |
| | | public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){ |
| | | CoreConstantManage.sleepBigBusy = sleepBigBusy ; |
| | | CoreConstantManage.sleepSmallBusy = sleepSmallBusy ; |
| | | public void setSleep(Long coreInterval){ |
| | | this.coreInterval = coreInterval ; |
| | | } |
| | | |
| | | public void start(){ |
| | |
| | | List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks(); |
| | | if (constantTasks != null && constantTasks.size() > 0) { |
| | | for (CoreTask task : constantTasks) { |
| | | new CoreConstantThread(sleepBigBusy, sleepSmallBusy, task).start(); |
| | | //new CoreConstantThread(sleepBigBusy, sleepSmallBusy, task).start(); |
| | | coreConstantTimers.add(new CoreConstantTimer(coreInterval, task).start()); |
| | | } |
| | | } |
| | | } |