void (List<VFileEvent> events) { var futures = new ArrayList<CompletableFuture<List<VFileEvent>>>(ourParallelism); for (var i = 0; i < ourParallelism; i++) { futures.add(CompletableFuture.supplyAsync(() -> { var threadEvents = new ArrayList<VFileEvent>(); try { processQueue(threadEvents); } catch (RefreshCancelledException ignored) { } catch (ProcessCanceledException | CancellationException e) { myCancelled = true; } catch (Throwable t) { LOG.error(t); myCancelled = true; } return threadEvents; }, ourExecutor)); } for (var future : futures) { try { events.addAll(future.get()); } catch (InterruptedException ignored) { } catch (ExecutionException e) { LOG.error(e); } } if (myCancelled) { LOG.trace("refresh cancelled"); } }