ExecutorService threadPool = Executors.newFixedThreadPool(1);
CompletionService<Object> completeService = new ExecutorCompletionService<Object>(
threadPool);
for (final HttpContentRetriever retriver : httpContentRetrievers) {
completeService.submit(new Runnable() {
@Override
public void run() {
try {
performParseAndAggregate(retriver.getInputStream(),
filePath, startDate, endDate, parserTyper,
pivotCallback);
} catch (Exception e) {
e.printStackTrace();
}
}
}, null);
}
for (int i = 0; i < httpContentRetrievers.length; i++) {
try {
completeService.take();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
threadPool.shutdown();
Iterator<Map<String, Object>> iter = pivotCallback.createView()
.listAll();
多线程处理
最新推荐文章于 2022-10-28 18:20:09 发布