package com.dashitech.utils;

import java.util.concurrent.*;

/**
 * Created by chi on 2020/8/25.
 */

public abstract class ThreadPoolFactory {
   // private static final Logger LOG = LoggerFactory.getLogger(ThreadPoolFactory.class);
    private static ThreadPoolExecutor pool;
    private static ScheduledThreadPoolExecutor scheduler;

    public synchronized static ExecutorService getCachedPool() {
        if (pool == null) {
            pool = (ThreadPoolExecutor) Executors.newCachedThreadPool();
         //   LOG.info("缓存线程池启动完成！初始化线程池大小：" + pool.getPoolSize());
        }
        return pool;
    }

    public synchronized static ScheduledExecutorService getScheduledPool() {
        if (scheduler == null) {
            scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5);
           // LOG.info("定时线程池启动完成！初始化线程池大小：" + scheduler.getPoolSize());
        }
        return scheduler;
    }

}

