线程相关

186 阅读1分钟
手动创建线程池
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(40, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
预启动核心线程
threadPoolExecutor.prestartAllCoreThreads();
提交线程(带返回值)实现Callable接口
Future<Boolean> futureResult = threadPoolExecutor.submit(new TaskThread(kettleInfoDO, dataSourceBean));
提交线程(无返回值)继承Thread或实现Runnable接口
threadPoolExecutor.execute(new TaskThread(kettleInfoDO, dataSourceBean))

线程池创建工具
private final static ExecutorService EXECUTOR = ThreadUtil.newExecutor(4, 8, 100);