线程池方法添加

back_recharge
duhui 2022-10-20 16:37:16 +08:00
parent 9f042f4030
commit 453584cea0
3 changed files with 23 additions and 5 deletions

View File

@ -44,14 +44,10 @@ public class GameApplication {
public static void main(String[] args) throws Exception {
start = true;
ConfigurableApplicationContextManager.init(args);
//init servercfg
ServerConfiguration serverConfiguration = ConfigurableApplicationContextManager.getBean(ServerConfiguration.class);
serverProperties = serverConfiguration.getServerProperties();
serverId = serverProperties.getId();
// CoreSettings coreSettings = ConfigurableApplicationContextManager.getBean(CoreSettings.class);
// GameApplication.areaId = coreSettings.getArea();
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
initReportLog();
MongoUtil.getInstence().init();

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.thread.ThreadManager;
import com.ljsd.jieling.util.*;
import config.SChongRank;
import config.SChongRankInfo;
@ -50,7 +51,7 @@ public class OpenServerCompeteRankActivity extends AbstractActivity {
int rankType = rankInfo.getRankType();
try {
long endTime = getEndTime(rankType);
TaskKit.scheduleOne(() -> sendReward(rankType), endTime, TimeUnit.MILLISECONDS);
ThreadManager.scheduleOne(() -> sendReward(rankType), endTime, TimeUnit.MILLISECONDS);
LOGGER.info("===========================冲榜初始化:{}-{}-{}",id,rankType,endTime);
}catch (Exception e){
LOGGER.error("冲榜初始化异常,id:{},type:{}",id, rankType);

View File

@ -131,6 +131,27 @@ public class ThreadManager implements IManager {
return scheduledExecutor;
}
/**
*
* @param task
* @param startTime
* @param unit
*/
public static void scheduleOne(final Runnable task, long startTime, final TimeUnit unit) {
scheduledExecutor.schedule(task,startTime,unit);
}
/**
*
* @param task
* @param initialDelay
* @param period ()
* @param unit
*/
public static ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
return scheduledExecutor.scheduleAtFixedRate(task, initialDelay, period, unit);
}
public static void reStart(){
LOGGER.info("重启线程池!!");
// scheduledExecutor.shutdown();