Callable

1346 단어 callable
반환 값 이 있 으 면 항목 을 더욱 명확 하 게 할 수 있 습 니 다.
Executor Service Callable Complete Service 의 관계
레 퍼 런 스 
http://blog.csdn.net/yanhandle/article/details/9037401

public List<StatisticErrorBean> statisticAllProducerLog(
			final String reportS, final String[] urls) throws IOException,
			ParseException, InterruptedException, ExecutionException {

		List<StatisticErrorBean> resultList = new ArrayList<StatisticErrorBean>();
		final String mainFolder = "/opt/sasuapps/itrc/logs";

		// use multi thread to filter/download/parser log
		ExecutorService es = Executors.newFixedThreadPool(10);
		CompletionService<List<StatisticErrorBean>> cs = new ExecutorCompletionService<List<StatisticErrorBean>>(
				es);

		for (final String url : urls) {
			cs.submit(new ProducerErrorFuture(url, client, mainFolder, reportS,
					this));
		}

		for (int i = 0; i < urls.length; i++) {
			List<StatisticErrorBean> list = cs.take().get();
			combineList(resultList, list);

		}
		es.shutdown();

		return resultList;
	}

좋은 웹페이지 즐겨찾기