Note that there are some explanatory texts on larger screens.

plurals
  1. POFiledialog is killing my thread
    text
    copied!<p>Im working on a <strong>socket</strong> program in Java. Im running a <strong>GUI</strong> with a socket server in the background. The <strong>socket</strong> server is running a <strong>thread</strong> that checks for <strong>socket</strong> messages every 10ms. Both of them runs fine together but as soon as I try to open my File dialog in the <strong>gui</strong>, the <strong>gui</strong> crashes, but the server keeps on running. Im thinking that I run the server (or the server <strong>thread</strong>) in a wrong way. The file dialog works fine if I skip the <strong>socket</strong>.</p> <p>What could be the problem, could it be that Im running the thread in a wrong way?</p> <p>(this in one class)</p> <pre><code>public ServerController(){ ServSocket st = new ServSocket(); Thread thread1=new Thread(st); thread1.start(); } </code></pre> <p>(this is my thread)</p> <pre><code>public void run(){ while (true) { try { Thread.sleep(10); } catch (InterruptedException e) {} switch (Status) { case CONNECTED: try { socket = new Socket(hostIP, port); System.out.println("Connected on: " + hostIP + port); out = new PrintWriter(socket.getOutputStream(), true); changeStatus(STARTSENDING, true); } catch (IOException e) { System.out.println("disconnected"); } break; </code></pre> <p>(and this is my main)</p> <pre><code> static ServerController scon; static Controller cn; public static void main(String[] args) { scon = new ServerController(); cn = new Controller(); cn.gui(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload