Code RoomBatch executor not shut down
MediumPrep Room Coding #2055

Batch executor not shut down

Code reviewConcurrencyMid–Senior~26 min

Review this Java method that parallelizes a batch of tasks with its own executor.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 26 min
Mark a line and say what kind of problem it is.0 findings
1List<Result> runBatch(List<Task> tasks) throws Exception {
2 ExecutorService pool = Executors.newFixedThreadPool(8);
3 List<Future<Result>> futures = new ArrayList<>();
4 for (Task t : tasks) {
5 futures.add(pool.submit(() -> process(t)));
6 }
7 List<Result> out = new ArrayList<>();
8 for (Future<Result> f : futures) {
9 out.add(f.get()); // may throw
10 }
11 return out;
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.