File tree Expand file tree Collapse file tree 3 files changed +44
-33
lines changed
springboot-dubbo-web/src/main/java/com/lzq/web/config Expand file tree Collapse file tree 3 files changed +44
-33
lines changed Original file line number Diff line number Diff line change 5
5
/springboot-dubbo-web /src /test /
6
6
/springboot-dubbo-web /src /main /resources /rebel.xml
7
7
/springboot-dubbo-service /src /test /
8
+ /.idea /
Original file line number Diff line number Diff line change
1
+ package com .lzq .web .config ;
2
+
3
+ import org .springframework .aop .interceptor .AsyncUncaughtExceptionHandler ;
4
+ import org .springframework .context .annotation .Configuration ;
5
+ import org .springframework .scheduling .annotation .AsyncConfigurer ;
6
+ import org .springframework .scheduling .annotation .EnableAsync ;
7
+ import org .springframework .scheduling .concurrent .ThreadPoolTaskExecutor ;
8
+
9
+ import java .util .concurrent .Executor ;
10
+
11
+ /**
12
+ * @author :LZQ
13
+ * @description:TODO
14
+ * @date :2021/9/24 9:17
15
+ */
16
+ @ Configuration
17
+ @ EnableAsync
18
+ public class AsyncTaskConfig implements AsyncConfigurer {
19
+ @ Override
20
+ public Executor getAsyncExecutor () {
21
+ ThreadPoolTaskExecutor threadPool = new ThreadPoolTaskExecutor ();
22
+ //设置核心线程数
23
+ threadPool .setCorePoolSize (10 );
24
+ //设置最大线程数
25
+ threadPool .setMaxPoolSize (100 );
26
+ //线程池所使用的缓冲队列
27
+ threadPool .setQueueCapacity (10 );
28
+ //等待任务在关机时完成--表明等待所有线程执行完
29
+ threadPool .setWaitForTasksToCompleteOnShutdown (true );
30
+ // 等待时间 (默认为0,此时立即停止),并没等待xx秒后强制停止
31
+ threadPool .setAwaitTerminationSeconds (60 );
32
+ // 线程名称前缀
33
+ threadPool .setThreadNamePrefix ("ScreenShot-Async-" );
34
+ // 初始化线程
35
+ threadPool .initialize ();
36
+ return threadPool ;
37
+ }
38
+
39
+ @ Override
40
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler () {
41
+ return null ;
42
+ }
43
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments