package com.yida.data.mall.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 getBillOrderThreadPool() {
        ThreadFactory threadFactory = ThreadUtil.newNamedThreadFactory("bill-order-pool-%d", false);
        return new ThreadPoolExecutor(5, 10, 1,
                TimeUnit.MINUTES, new LinkedBlockingQueue<>(), threadFactory);
    }
}
