/**
 * Copyright
 * All right reserved.
 * 项目名称:运维系统
 * 创建日期:2022/5/23
 */
package org.springblade.jobtask;


import lombok.extern.slf4j.Slf4j;
import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

import java.util.concurrent.*;

/***
 * Date:2022/5/22
 * Title: 任务执行线程池
 * Description：任务执行线程池
 * @author swp
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Slf4j
@Component
@EnableScheduling
public class TaskManager {

	/**
	 * 公共线程池
	 **/
	private static ThreadFactory publicThreadFactory = new ThreadFactoryBuilder().setNameFormat("task-thread-pool-%d").build();
	private static ExecutorService publicThreadPool = new ThreadPoolExecutor(2, 4,
		0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024), publicThreadFactory, new ThreadPoolExecutor.AbortPolicy());

	public void submitTask(FutureTask<Integer> futureTask) {
		publicThreadPool.execute(futureTask);
	}
}
