This commit is contained in:
雷欧(林平凡)
2024-11-29 11:56:41 +08:00
parent 2a77c74ba8
commit a89d8e3377

View File

@@ -6,6 +6,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/** /**
* @author Leo * @author Leo
@@ -20,11 +21,10 @@ public class AsyncConfig implements AsyncConfigurer {
@Override @Override
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(8); executor.setCorePoolSize(10);
executor.setMaxPoolSize(128); executor.setMaxPoolSize(128);
executor.setQueueCapacity(100); executor.setQueueCapacity(500);
executor.setThreadNamePrefix("Async-"); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize(); executor.initialize();
return executor;
} }
} }