package com.jkcredit.invoice.service.thead;

import java.util.concurrent.*;

/**
 * 连接池工厂类
 * @author mumuxigua
 */
public class ThreadPoolFactory {

    public static ExecutorService getThreadPool(String name, int coreSize, int maxSize) {
        ExecutorService executorService = new ThreadPoolExecutor(coreSize, maxSize, 2000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(2000), new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, name);
            }
        });
        return executorService;
    }
}
