title: Separate Thread won't run, blocking main UI
body: <p>I have a program which executes a set of PowerShell commands. Now the thing is that i need to update the status of a label and show an icon at the time when the user clicks a certain option and the process of executing commands starts. If i just type the commands before the try-catch statement they are executed at the end after the whole try-catch statement end. So i tried running them on a separate Thread in the code provided bellow, but in this case they are not even executed, just the try-catch block is. The method NORMAL_MODE() is triggered by mouse click.</p>
  
  <pre><code>@FXML
      private void NORMAL_MODE(){
          new Thread(new Runnable() {
              @Override
              public void run() {
                  LABEL.setText("123");
                  ICON.setVisible(true);
              }
          }).start();
          try (PowerShell powerShell = PowerShell.openSession()) {
              PowerShellResponse response = powerShell.executeCommand("Set-Location “C:\\Windows\\Temp”");
              response = powerShell.executeCommand("Remove-Item * -whatif -recurse -force");
              System.out.println(response.getCommandOutput());
              response = powerShell.executeCommand("Set-Location “C:\\Windows\\Prefetch”");
              response = powerShell.executeCommand("Remove-Item * -whatif -recurse -force");
              System.out.println(response.getCommandOutput());
              response = powerShell.executeCommand("Set-Location “C:\\Documents and Settings”");
              response = powerShell.executeCommand("Remove-Item * -whatif -recurse -force");
              System.out.println(response.getCommandOutput());
              response = powerShell.executeCommand("Set-Location $env:TEMP");
              System.out.println(response.getCommandOutput());
              response = powerShell.executeCommand("Remove-Item -whatif -Recurse -Force");
              System.out.println(response.getCommandOutput());
          } catch(PowerShellNotAvailableException ex) {
          }
      }
  </code></pre>