多线程处理业务逻辑思路:
代码实例:
final CountDownLatch latch = new CountDownLatch(2);
ExecutorService threadPool = Executors.newFixedThreadPool(2);
Callable<Integer> c = new Callable<Integer>() {
public Integer call() throws Exception {
latch.countDown();
return jbosskucunMapper.countByMaper(map);
}
};
Callable<Integer> cc = new Callable<Integer>() {
public Integer call() throws Exception {
latch.countDown();
return userEvaluateMapper.countByExample(example);
}
};
try {
Cailiaochanp = threadPool.submit(c).get();
Userchanpcount = threadPool.submit(cc).get();
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}