haungxing
4 months ago
23 changed files with 235 additions and 90 deletions
@ -1,5 +0,0 @@
|
||||
build.artifact=hzims-service-api |
||||
build.group=com.hnac.hzims |
||||
build.name=hzims-service-api |
||||
build.time=2024-07-22T06\:45\:56.469Z |
||||
build.version=4.0.0-SNAPSHOT |
@ -0,0 +1,34 @@
|
||||
|
||||
package com.hnac.hzims.alarm.monitor.listener; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.concurrent.*; |
||||
|
||||
/** |
||||
* @author: ysj |
||||
*/ |
||||
@Component |
||||
public class AlarmPoolManager { |
||||
|
||||
@Bean |
||||
public ThreadPoolExecutor threadPoolExecutor() { |
||||
// 核心线程数
|
||||
int corePoolSize = 8; |
||||
// 最大线程数
|
||||
int maximumPoolSize = 16; |
||||
// 线程空闲时的存活时间
|
||||
long keepAliveTime = 60L; |
||||
// 时间单位
|
||||
TimeUnit unit = TimeUnit.SECONDS; |
||||
// 任务队列
|
||||
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(100); |
||||
// 线程工厂
|
||||
ThreadFactory threadFactory = Executors.defaultThreadFactory(); |
||||
// 等待策略
|
||||
RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy(); |
||||
return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.hnac.hzims.alarm.ws.alart; |
||||
|
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public class AlarmSocketPool { |
||||
|
||||
public static Map<String, AlarmHandler> pool = new ConcurrentHashMap<>(); |
||||
|
||||
} |
Loading…
Reference in new issue