package com.itant.shiwushu.manager;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by Jason on 2018/10/7.
 */

public class ExecutorManager {
    private static final int NUMBER_THREAD = 5;
    private static ExecutorManager instance;
    private ExecutorService fixedExecutor;

    private ExecutorManager() {
        fixedExecutor = Executors.newFixedThreadPool(NUMBER_THREAD);
    }

    public static ExecutorManager getInstance() {
        if (instance == null) {
            init();
        }
        return instance;
    }

    private static synchronized void init() {
        if (instance == null) {
            instance = new ExecutorManager();
        }
    }

    public ExecutorService getFixedExecutor() {
        return fixedExecutor;
    }
}
