List of utility methods to do Thread Future
CompletableFuture | waitForAll(List Return a future that represents the completion of the futures in the provided list return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); |
void | waitForAll(List For lists of Future results that we are uninterested in, act as a Barrier and attempt to get all futures. for (Future<?> f : res) try { f.get(); } catch (InterruptedException | ExecutionException e) { |
void | waitForCompletion(Collection Blocks and waits for all Futures in the given collection to complete. for (Future<?> future : futures) { try { future.get(); } catch (ExecutionException ex) { throw new RuntimeException("Exception during execution", ex); } catch (InterruptedException ex) { throw new RuntimeException("Thread interrupted", ex); |
void | waitForCompletion(Future>[] futures) Waits for all threads to complete computation. int size = futures.length; try { for (int j = 0; j < size; j++) { futures[j].get(); } catch (ExecutionException ex) { ex.printStackTrace(); } catch (InterruptedException e) { ... |
int | waitForTasks(List wait For Tasks int total = 0; for (Future future : futures) { try { future.get(); total++; } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); futures.clear(); return total; |