Skip to content

Instantly share code, notes, and snippets.

@thrakt
Created May 19, 2014 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thrakt/19ffd822ab16234daeb8 to your computer and use it in GitHub Desktop.
Save thrakt/19ffd822ab16234daeb8 to your computer and use it in GitHub Desktop.
Java8でListをある程度まとめて並列処理 ref: http://qiita.com/thrakt/items/62d05c2ea0675f0f996f
List<Map<String, Object>> rows = new ArrayList<>(); // データ入れる
rows.parallelStream().forEach(row -> {
LOG.info("something to do.");
LOG.info(row);
});
List<Map<String, Object>> rows = new ArrayList<>(); // データ入れる
for (int start = 0; start < rows.size();) {
int end = start + 100;
if (end > oldRows.size()) {
end = oldRows.size();
}
List<Map<String, Object>> subList = rows.subList(start, end);
ForkJoinPool.commonPool().execute(() -> {
LOG.info("something to doooooooooooooo.");
subList.forEach(row -> {
LOG.info(row);
});
});
start = end;
}
});
// 終了待機
while (!ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.HOURS));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment