SHARE
TWEET

Untitled

a guest Jun 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List<Future> futures = new ArrayList<Future>();
  2.  
  3. futures.add(task1());
  4. futures.add(task2());
  5.      
  6. // Option 1
  7. for (Future future : futures) {
  8.   results.add(future.get());
  9. }
  10.  
  11. // Option 2
  12. boolean incompleteFound;
  13. do {
  14.  incompleteFound = false;
  15.  for (Future future : futures) {
  16.     if (!future.isDone()) {
  17.       incompleteFound = true;
  18.     }
  19.  }
  20. } while (incompleteFound);
  21.  
  22. for (Future future : futures) {
  23.   results.add(future.get());
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top