package cn.superdesk.uniorder.executor.scheduler.config.thread;


import cn.superdesk.uniorder.common.spring.SpringContextHolder;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 用于获取自定义线程池
 * @Author: linjinyu
 * @CreateDate: 2020/12/23 下午2:16
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/23 下午2:16
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class ThreadPoolExecutorUtil {

	public static ThreadPoolExecutor getPoll() {

		AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);

		return new ThreadPoolExecutor(
				properties.getCorePoolSize(),
				properties.getMaxPoolSize(),
				properties.getKeepAliveSeconds(),
				TimeUnit.SECONDS,
				new ArrayBlockingQueue<>(properties.getQueueCapacity()),
				new TheadFactoryName()
		);
	}
}
