| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.core; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.logging.log4j.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class CoreConstantManage { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final static Logger log = LogManager.getLogger(CoreConstantManage.class.getName()) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final static CoreConstantManage instance = new CoreConstantManage() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<CoreConstantTimer> coreConstantTimers ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Long coreInterval = 100L ;//核心线程暂停间隔 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CoreConstantManage(){ | 
|---|
|  |  |  | coreConstantTimers = new ArrayList<>() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static CoreConstantManage getInstance(){ | 
|---|
|  |  |  | return instance ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设置暂停时长 | 
|---|
|  |  |  | * @param coreInterval 核心线程暂停间隔 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | coreConstantTimers.add(new CoreConstantTimer(coreInterval, task).start()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|