-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
线程池配置以及关闭线程池优化 #88
base: main
Are you sure you want to change the base?
线程池配置以及关闭线程池优化 #88
Conversation
@@ -58,6 +61,7 @@ public ThreadPoolTaskExecutor websocketExecutor() { | |||
executor.setThreadNamePrefix("websocket-executor-"); | |||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());//满了直接丢弃,默认为不重要消息推送 | |||
executor.setThreadFactory(new MyThreadFactory(executor)); | |||
executor.setPrestartAllCoreThreads(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此处感觉没必要直接启动所有核心线程等待
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面代码,推动消息给所有在线的人,ONLINE_WS_MAP是所有在线等人数,而且核心线程启动还是需要的
如果初始化时不启动所有核心线程,很短时间内也是会调用所有核心线程的
public void sendToAllOnline(WSBaseResp<?> wsBaseResp, Long skipUid) {
ONLINE_WS_MAP.forEach((channel, ext) -> {
if (ObjectUtil.equal(ext.getUid(), skipUid)) {
return;
}
threadPoolTaskExecutor.execute(() -> sendMsg(channel, wsBaseResp));
});
}
# Conflicts: # mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/sensitiveWord/ACFilter.java
线程池配置优化以及优雅关闭线程池