title: Javafx Task running intermittently
body: <p>I'm running FX8 (JDK8_u25) and have the following code</p>
  
  <pre><code>private void initializeBrokerCommunication()
  {
      System.out.println("0");
      try {
          Task&lt;List&lt;Integer&gt;&gt; initTask = new Task&lt;List&lt;Integer&gt;&gt;() {
              @Override
              protected List&lt;Integer&gt; call() throws Exception
              {
                  System.out.println("1");
                  Thread.sleep(500);
                  DateTime upperBound = new DateTime(masterXAxis.getUpperBound());
                  DateTime lowerBound = new DateTime(masterXAxis.getLowerBound());
                  int seconds = Seconds.secondsBetween(lowerBound, upperBound).getSeconds();
                  lowerBound = lowerBound.minusSeconds(seconds);
                  System.out.println("2");
                  return broker.getDeviceData(null, upperBound.toDate(), lowerBound.toDate(), true);
  
              }
          };
          // setOnSucceeded ensures that the method processHistoricData runs on the Fx thread.
          initTask.setOnSucceeded(event -&gt; {
              System.out.println("3");
              processHistoricData(initTask.valueProperty().getValue(), true);
          });
          // submit the task and the scheduler decides when to run it.
          scheduler.submit(initTask);
      }
      catch (Exception e) {
          e.printStackTrace();
      }
      System.out.println("4");
  }
  </code></pre>
  
  <p><code>scheduler</code> is a <code>ScheduledExecutorService</code> object and is initialized as follows
  <code>ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(5);</code></p>
  
  <p>initializeBrokerCommunication() method is wrapped in a class that extends Application class. Multiple runs of my class produces different outputs each time.</p>
  
  <p><code>0-4-1-2-3</code> is what I expect, but sometimes I see <code>0-4</code> being printed and don't see <code>1-2-3</code> even being printed.</p>
  
  <p>Any pointers as to why task runs intermittently.</p>