public class I2pThreadUtils {
private static Logger logger = LoggerFactory.getLogger(MultiThreadUtils.class);
// 线程个数,如不赋值,默认为5
private int threadCount = 20;
// 具体业务任务
// private I2pTask, T> task;
// 线程池管理器
private CompletionService pool = null;
public static I2pThreadUtils newInstance(int threadCount) {
I2pThreadUtils instance = new I2pThreadUtils();
threadCount = threadCount;
instance.setThreadCount(threadCount);
return instance;
}
@SuppressWarnings("rawtypes")
public ResultBean execute(List data, Map params, ITask, T> task) {
// 创建线程池
int num = 0;
ExecutorService threadpool = Executors.newFixedThreadPool(threadCount);
// 根据线程池初始化线程池管理器
pool = new ExecutorCompletionService(threadpool);<