Code Room
Code reviewMediumcr-g428
Subject Resource leaksLevel Mid–Senior~26 minCommon in Concurrency interviewsIndustries Software development

Question

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.

Talk through your review
Code to reviewjava
List<Result> runBatch(List<Task> tasks) throws Exception {  ExecutorService pool = Executors.newFixedThreadPool(8);  List<Future<Result>> futures = new ArrayList<>();  for (Task t : tasks) {    futures.add(pool.submit(() -> process(t)));  }  List<Result> out = new ArrayList<>();  for (Future<Result> f : futures) {    out.add(f.get());      // may throw  }  return out;}
Run or narrate your approach, then ask the coach.