// 不止一页,则需要分页调用
String totalStr = accountInfo.getTotal();
int totalInt = Integer.parseInt(totalStr);
final int pageSize = 2000; //内部类调用需定义为私有
int pageNum = totalInt%pageSize == 0 ? totalInt/pageSize : totalInt/pageSize+1;
// 保存微服务返回来的数据
saveRpcCustomers(accountInfo.getRows(), batchNo);
//1、 创建CountDownLatch 对象, 设定需要计数的子线程数目
final CountDownLatch latch = new CountDownLatch(pageNum-1);
for(int i=2;i<=pageNum;i++)
{
final int f = i;
new Thread(){
@Override
public void run() {
TcmAccountInfo accountInfoTemp = TcmAccountInfoService.batchQueryClientDetails(String.valueOf(f),String.valueOf(pageSize));
saveRpcCustomers(accountInfoTemp.getRows(), batchNo);
//2、子线程执行完毕,计数减1
latch.countDown();
}
}.start();
}
//3、 当前线程挂起等待 ,所有线程执行完,才往下执行主线程
latch.await();
// 将中间表中的数据刷新到正式表中
integrationDao.temp2Customer(batchNo);