title: JAVA FX - Service.start() wont run in a separate thread
body: <p>I have and application and i start my scene in the primaryStage.</p>
  
  <p>When the user click OK button, I create a Service and after that, I start it. This service make a call to WebService and get me the response. <strong>I've seen that after the start() is called, the main flow do not continue and createTask() is called immediately</strong> and all my <code>UI</code> is blocked. This is my code:</p>
  
  <p><strong>Code when I press the button</strong></p>
  
  <pre><code>@FXML
      private void handleRegisterButton() {
  
          User newUser = new User();
          newUser.setUsername(usernameTextField.getText());
          newUser.setGroup(groupChoicheBox.getSelectionModel().getSelectedItem());
          newUser.setMachineName(machineNameTextField.getText());
  
          RegisterUserInvocation service = new RegisterUserInvocation(newUser);
  
          service.stateProperty().addListener(new InvalidationListener() {
              @Override
              public void invalidated(Observable observable) {
                  System.out.println("Task value " + service.getState());
                  if(service.getState().equals(Worker.State.SUCCEEDED))
                      System.out.println("SUCCEEDED");
              }
          });
  
          service.start();
  
          this.mainApp.getPrimaryStage().close();
      }
  </code></pre>
  
  <p><strong>Code of RegisterUserInvocation</strong></p>
  
  <pre><code>public class RegisterUserInvocation extends Service&lt;Integer&gt;{
      private User user;
  
      public RegisterUserInvocation(User user) {
          this.user = user;
      }
  
      @Override
      protected Task&lt;Integer&gt; createTask() {
          String url = "http://localhost:8080/LANServer/services/Rest/user/";
          Client client = ClientBuilder.newClient();      
          Integer resp = client.target(url).request().post(Entity.entity(user, MediaType.APPLICATION_JSON), Integer.class);
  
          return new Task&lt;Integer&gt;() {
              @Override
              protected Integer call() throws Exception {
                  return resp;
              }
          };
      }
  }
  </code></pre>