//线程池初始化 int thread = 3; ExecutorService executorService = Executors.newFixedThreadPool(thread); final CountDownLatch countDownLatch = new CountDownLatch(thread);
//线程执行
executorService.submit(new Callable() { @Override public Object call() throws Exception { AMapper.select(); countDownLatch.countDown(); return null; } });
executorService.submit(new Callable() { @Override public Object call() throws Exception { BMapper.select(); countDownLatch.countDown(); return null; } });
executorService.submit(new Callable() { @Override public Object call() throws Exception { CMapper.select(); countDownLatch.countDown(); return null; } });
try { countDownLatch.await(); //组装数据 } catch (InterruptedException e) { e.printStackTrace(); }