title: Calling Platform.runLater for multiple tasks in javaFX application
body: <p>I have a JavaFX application which has several methods attached to it and there is one method like everything that calls all methods
  like </p>
  
  <pre><code>DFF
  Lookup
  Profile
  Everything
  </code></pre>
  
  <p><code>Everything</code> calls all these methods I am trying to implement threading on <code>Everything</code> methods to call these methods and then after the <code>List</code>s are popuplated I transfer the control to another fxml to display it in table view using tab pane.</p>
  
  <pre><code>public void runEverything(){
      List&lt;Task&gt; tasks = new ArrayList();
  
      Task task = new Task() {
          protected Object call() throws Exception {                
              dataAOL = aol.getAolReport(InstanceController.validateto, InstanceController.validatefrom, pattern.getText());
              System.out.println("Method"+AOLScreenController.dataAOL.size());             
  
              return null;
          } 
  
      };
      Task task1 = new Task() {
          protected Object call() throws Exception {                
              dataProfile = aol.getAolReport(InstanceController.validateto, InstanceController.validatefrom, pattern.getText());
              System.out.println("Method"+AOLScreenController.dataAOL.size());                
  
              return null;
          } 
  
      };
  
      tasks.add(task);
      tasks.add(task1);
  
      ExecutorService threadPool = Executors.newFixedThreadPool(5);
      for (Task t : tasks) {               
          threadPool.submit(t);
      }
      threadPool.shutdown();
  }
  </code></pre>
  
  <p>I need to call the <code>Platform.runLater</code> method only once after all threads have finished execution so that I load the fxml view and in the means while a progress bar will loop in the new fxml and ui will not lag .
  but I do not know where to place my <code>Platform.runLater</code> code</p>
  
  <pre><code>Platform.runLater(new Runnable() {
       @Override public void run() {
           try {
               Parent parent = FXMLLoader.load(getClass().getResource("AolRun.fxml"));
               SmartCC.fxmlval.add("AOLScreen.fxml");
               SmartCC.stageval.add((Stage) run.getScene().getWindow());
               Stage stage = new Stage();
               stage.initStyle(StageStyle.UTILITY);
               stage = (Stage) run.getScene().getWindow();
               Scene scene = new Scene(parent);
               stage.setScene(scene);
               scene.getStylesheets().add("/css/Style.css");
               stage.setTitle("AOL Output ");
               stage.setResizable(false);
               stage.show();
           } catch (IOException ex) {
               Logger.getLogger(AOLScreenController.class.getName()).log(Level.SEVERE, null, ex);
           }
       }
   });
  </code></pre>
  
  <p>If I place it inside the last task there is thread synchronization errors and I do not know about that.<br>
  I am very new to threads and javafx threads please help</p>