package com.zdc.service;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 线程池
* @author lenovo
*
*/
public class ExcutePool {
private ExecutorService executorService;
/**
*
* @param poolSize 允许的线程数量
* @param queSize 队列数量
*/
public ExcutePool(int poolSize,int queSize) {
executorService = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),poolSize, 10L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queSize));
}
public void execute(Runnable task){
executorService.execute(task);
}
}