/**
-
@BelongsProject: enniu-net-service
-
@BelongsPackage: cn.enncloud.enniu.integration.client.data
-
@Author: 这个线程池执行器可以用于执行大量的并发任务,提高系统的性能。
-
@CreateTime: 2023-08-18 15:58
-
@Description:
-
@Version: 1.0
*/
@Configuration
public class PoolExecutorServiceConfig {@Bean public ExecutorService executorService() { return RDFAExecutor.Builder.newInstance("ENN-SERVICE") //线程池的核心线程数为2 .corePoolSize(CommonConstants.TWO) //不允许超时 .allowCoreThreadTimeOut(false) //最大线程 .maximumPoolSize(Runtime.getRuntime().availableProcessors() * 2) //等待队列长度,默认20 .blockingQueueSize(CommonConstants.TWENTY) //线程空闲后的存活时间为30秒 .keepAliveTimeInSeconds(CommonConstants.THIRTY) //此处拒绝策略保证数据不丢失 .rejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()) .build(); }
}