title: When does the call() method get called in a Java Executor using Callable objects?
body: <p>This is some sample code from an <a href="http://blogs.oracle.com/CoreJavaTechTips/entry/get_netbeans_6" rel="nofollow noreferrer">example</a>. What I need to know is when <code>call()</code> gets called on the callable? What triggers it?</p>
  
  <pre><code>public class CallableExample {
  
  public static class WordLengthCallable
      implements Callable {
      private String word;
      public WordLengthCallable(String word) {
        this.word = word;
      }
      public Integer call() {
        return Integer.valueOf(word.length());
      }
  }
  
  public static void main(String args[]) throws Exception {
      ExecutorService pool = Executors.newFixedThreadPool(3);
      Set&lt;Future&lt;Integer&gt;&gt; set = new HashSet&lt;Future&lt;Integer&gt;&gt;();
      for (String word: args) {
        Callable&lt;Integer&gt; callable = new WordLengthCallable(word);
        Future&lt;Integer&gt; future = pool.submit(callable); //**DOES THIS CALL call()?**
        set.add(future);
      }
      int sum = 0;
      for (Future&lt;Integer&gt; future : set) {
        sum += future.get();//**OR DOES THIS CALL call()?**
      }
      System.out.printf("The sum of lengths is %s%n", sum);
      System.exit(sum);
    }
  }
  </code></pre>