public static final ThreadPoolExecutor createThreadPool(int threadCount, int queueSize, NulsThreadFactory factory) {
if (threadCount == 0) {
throw new RuntimeException("thread count cannot be 0!");
}
if (factory == null) {
throw new RuntimeException("thread factory cannot be null!");
}
Class[] paramClasses = new Class[]{int.class, int.class, long.class, TimeUnit.class, BlockingQueue.class, ThreadFactory.class};
Object[] paramArgs = null;
if (queueSize > 0) {
paramArgs = new Object[]{threadCount, threadCount, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(queueSize), factory};
} else {
paramArgs = new Object[]{threadCount, threadCount, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(), factory};
}
ThreadPoolExecutor pool = AopUtils.createProxy(ThreadPoolExecutor.class, paramClasses, paramArgs, new ThreadPoolInterceiptor());
THREAD_DATA_CACHE.putPool(factory.getModuleId(), factory.getPoolName(), pool);
return pool;
}