update - 实用 @Async 注解,并自定义线程池

This commit is contained in:
wangli 2024-04-09 23:23:01 +08:00
parent dbaa74480f
commit 467a4890c6

View File

@ -35,6 +35,8 @@ public class SpringAsyncConfigurer extends AsyncConfigurerSupport {
executor.setKeepAliveSeconds(60);
//线程名字前缀
executor.setThreadNamePrefix("async-executor-");
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationMillis(60);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}