Skip to content

Instantly share code, notes, and snippets.

@JohannesSundqvist
Created November 14, 2018 15:19
Show Gist options
  • Save JohannesSundqvist/4901f0ebfc963f6a0ce92a25aff1292d to your computer and use it in GitHub Desktop.
Save JohannesSundqvist/4901f0ebfc963f6a0ce92a25aff1292d to your computer and use it in GitHub Desktop.
Map<String, List<Observation>> result = new TreeMap<String, List<Observation>>();
ExecutorService e = Executors.newCachedThreadPool();
for(Map.Entry<String, Map<LocalDate, Integer>> item : observations.entrySet()) {
Future<List<Observation>> f = e.submit(new GetObservationPart(start, end, item));
if(f.isDone()) {
Future<Map<String, List<Observation>>> f2 = e.submit(new MergeObservationParts(result, item.getKey(), f.get()));
if(f2.isDone()) {
result = f2.get();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment