import java.io.BufferedReader; import java.io.IOException; public class ServerListenerThread extends Thread { private final ChatClient owner; private final BufferedReader from_server; private boolean quit = false; public ServerListenerThread(ChatClient owner, BufferedReader from_server) { this.owner = owner; this.from_server = from_server; } public void run() { while (! quit) { String line_from_server; try { line_from_server = from_server.readLine(); if (line_from_server == null) { System.out.println("Fick inga data från servern"); quit = true; } else { System.out.println(line_from_server); } } catch (IOException e) { System.out.println("Fel vid mottagning från servern"); quit = true; } } // while owner.please_quit(); } // run public void please_quit() { quit = true; } } // class ServerListenerThread