title: ExecutorService InvokeAll Progress Bar
body: <p>I have an ExectorService and the following code, everything is working fine with the futures and the concurrency.  However, when I try to update my progress bar from SomeClass(), it seems to only update the UI after the invokeAll() is complete...basically the progress bar only updates once everything is complete which deems it useless.</p>
  
  <p>How can I resolve this?  I've looked at CompletionServices as well as SwingWorkers but I don't know how to apply them to my code.  Any assistance will be appreciated.</p>
  
  <pre><code>class SomeClass() {
    private static class Result {
      private final String someVar;
  
      public Result(String code) {
          this.someVar = code;
      }
    }
  
   public static Result compute(Object obj) {
     // ... compute stuff
     someVar = "computedResult";
     return Result(someVar);
   }
   public someFunction() {
      List&lt;Callable&lt;Result&gt;&gt; tasks = new ArrayList&lt;Callable&lt;Result&gt;&gt;();
      for (Object f : listOfObjects) {
          Callable&lt;Result&gt; c = new Callable&lt;Result&gt;() {
              @Override
              public Result call() throws Exception {
                  someClassUI.jProgressBar.setValue(50);
                  return compute(file);
              }
          };
          tasks.add(c); 
      }
  
      List&lt;Callable&lt;Result&gt;&gt; tasks = new ArrayList&lt;Callable&lt;Result&gt;&gt;();
      List&lt;Future&lt;Result&gt;&gt; results = executorService.invokeAll(tasks);
  
      for (Future&lt;Result&gt; fr : results) {
       String value = fr.get().resultValue;
      }
    }
  }
  
  class SomeClassUI {
    public static jProgressBar;
  
    public someClassUI() {
      jProgressBar = new JProgressBar(0,100);
    }
  
    private void button1ActionPerformed(ActionEvent e) {
      SomeClass theClass = new SomeClass();
      theClass.someFunction();
    }
  
  }
  </code></pre>
  
  <p><strong>edit</strong>: edited to add some extra code to help understanding</p>