title: ServerSocket started in different Thread makes JavaFX application to freeze
body: <p>I'm trying to create a terminal emulator with pty.js and xterm.js. I've never tried something like this before so If I say something wrong, I apologize, its because I didn't understand it correctly. Anyway, The terminal should be displayed inside a JavaFX <code>WebView</code> and all the GUI is ready and tested. From what I've found, I understood that there must be a server running on localhost in order for pty.js to spawn a shell there, and communicate the results through xterm.js on the <code>WebView</code>. Now, I'm trying to create a server using <code>ServerSocket</code> in a new <code>Thread</code> but when I test the application and click on the Terminal button, the application freezes. I've tested the server whether it is running or not by visiting my localhost and it was up and running. So, what I get is that the main Thread of the application takes a lower priority the moment the Server thread starts. Am I right? And if so, how can I solve this? </p>
  
  <p>The below function is called in the <code>initialize</code> method of the Terminal scene which is loaded from the main controller. Can somebody please explain why is this happening?</p>
  
  <pre><code>    private void createServerToSpawnPty() {
  
          Thread thread = new Thread(() -&gt; {
              try {
                  ServerSocket server = new ServerSocket(8080);
                  System.out.println("Created Java localhost server on port: 8080");
                  while (true) {
                      final Socket client = server.accept( );
                      System.out.println("client connected:+
                      client.isConnected( ));
                  }
  
               }catch (IOException exception) {
                  exception.printStackTrace( );
               }
           });
          thread.setDaemon(true);
          thread.run();
      }
  </code></pre>