@RequestMapping("syncProxyInfo")
public ReturnValue syncAgentInfo(HttpServletRequest request) {
long start=new Date().getTime();
try {
JSONObject jsonObject=CoreUtil.getBodyJSONObj(request);
JSONArray jsonArray=jsonObject.getJSONArray("data");
logger.info("proxysize:"+jsonArray.size());
logger.info(jsonArray.toJSONString());
if(jsonArray!=null&&!jsonArray.isEmpty()) {
//解析数据
List dataList=JSONArray.toJavaObject(jsonArray, List.class);
int size=dataList.size();
int copies=getCopies(size);
copies=copies>100?100:copies;//最大100个线程
ExecutorService esS=Executors.newFixedThreadPool(copies);
//将大数据拆分成几个小数据然后通过线程池同步并行执行.
List<List<List<String>>> result=Lists.partition(dataList, MAX_EACH_COUNT);
result.forEach(lists->{
esS.submit(()->{
analysisData(lists);
});
});
esS.shutdown();
while(true) {
if(esS.isTerminated()) {
long end=new Date().getTime();//263995
logger.info("用时"+(end-start)/1000+"秒");
return new ReturnValue(true);
}
}
}
}catch(Exception e) {
logger.error(e.getMessage());
return new ReturnValue(false,e.getMessage());
}
return new ReturnValue(false);
}
调用该接口 导致tomcat jvm 崩溃了
这个接口有两千条数据,每条数据需要查林外一个接口
异常日志不知道咋分析,为什么会有2000对个线程阻塞住了