package cn.net.caoyao.cpzshandset.service.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolManager {
	private static ThreadPoolExecutor threadPool;
	/** 线程池维护线程的最少数量 */
	private static final int DEFAULT_CORE_POOL_SIZE = 5;
	private static final int DEFAULT_MAXIMUM_POOL_SIZE = 10;
	/** 线程池维护线程所允许的空闲时间 */
	private static final int DEFAULT_KEEP_ALIVE_TIME = 0;

	private static int count = 0;
	public  static ThreadPoolExecutor getThreadPool(){
		if (threadPool == null){
			threadPool = new ThreadPoolExecutor(DEFAULT_CORE_POOL_SIZE,
					DEFAULT_MAXIMUM_POOL_SIZE, DEFAULT_KEEP_ALIVE_TIME,
					TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(3),
					new ThreadPoolExecutor.CallerRunsPolicy());
			count++;
//			LogUtil.e(TConfig.Echo, "count:" + count);

		}
		return  threadPool;
	}


}
