package com.yida.data.common.core.utils;

import cn.hutool.core.thread.ThreadUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.concurrent.*;

/**
 * 线程池工具类
 *
 * @author ZYJ
 * @date 2022/4/14
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ThreadPoolUtil {

    /**
     * 生成线程池
     *
     * @return java.util.concurrent.ExecutorService
     * @author ZYJ
     * @date 2022/4/14 10:10
     */
    public static ExecutorService getThreadPool(String threadName) {
        ThreadFactory threadFactory = ThreadUtil.newNamedThreadFactory(threadName, false);
        return new ThreadPoolExecutor(3, 6, 1,
                TimeUnit.MINUTES, new LinkedBlockingQueue<>(), threadFactory);
    }
}
