Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
2f9ad24f
提交
2f9ad24f
authored
9月 28, 2022
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文件位置
上级
45eeacae
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
1 行增加
和
46 行删除
+1
-46
ThreadConfig.java
src/main/java/com/yaoyaozw/customer/ThreadConfig.java
+0
-45
AsynchronousSpringEventsConfig.java
...aozw/customer/configs/AsynchronousSpringEventsConfig.java
+1
-1
没有找到文件。
src/main/java/com/yaoyaozw/customer/ThreadConfig.java
deleted
100644 → 0
浏览文件 @
45eeacae
package
com
.
yaoyaozw
.
customer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @author darker
* @date 2022/8/2 15:01
*/
@Configuration
@EnableAsync
public
class
ThreadConfig
{
/** 核心线程数(默认线程数) */
private
static
final
int
CORE_POOL_SIZE
=
15
;
/** 最大线程数 */
private
static
final
int
MAX_POOL_SIZE
=
50
;
/** 允许线程空闲时间(单位:默认为秒) */
private
static
final
int
KEEP_ALIVE_TIME
=
60
;
/** 缓冲队列大小 */
private
static
final
int
QUEUE_CAPACITY
=
100
;
/** 线程池名前缀 */
private
static
final
String
THREAD_NAME_PREFIX
=
"Async-Service-"
;
@Bean
(
"myExecutor"
)
public
ThreadPoolTaskExecutor
myExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
CORE_POOL_SIZE
);
executor
.
setMaxPoolSize
(
MAX_POOL_SIZE
);
executor
.
setQueueCapacity
(
QUEUE_CAPACITY
);
executor
.
setKeepAliveSeconds
(
KEEP_ALIVE_TIME
);
executor
.
setThreadNamePrefix
(
THREAD_NAME_PREFIX
);
// 线程池对拒绝任务的处理策略
// CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
// 初始化
executor
.
initialize
();
return
executor
;
}
}
src/main/java/com/yaoyaozw/customer/AsynchronousSpringEventsConfig.java
→
src/main/java/com/yaoyaozw/customer/
configs/
AsynchronousSpringEventsConfig.java
浏览文件 @
2f9ad24f
package
com
.
yaoyaozw
.
customer
;
package
com
.
yaoyaozw
.
customer
.
configs
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.event.ApplicationEventMulticaster
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论