fork download
  1.  
  2. import java.io.*;
  3. import java.net.*;
  4.  
  5. public class ServerThread extends Thread {
  6.  
  7. private Server_Side server;
  8. private Socket socket;
  9.  
  10. public ServerThread(Server_Side server, Socket socket){
  11. this.server = server;
  12. this.socket = socket;
  13. start();
  14.  
  15. }
  16.  
  17. public void run() {
  18.  
  19. try
  20. {
  21. DataInputStream iD = new DataInputStream(socket.getInputStream());
  22. while(true){
  23. String message = iD.readUTF();
  24. System.out.println("Sending: " + message);
  25. server.sendToAll(message);
  26. }
  27. }
  28. catch (EOFException ie){
  29. }
  30.  
  31. catch (IOException ie){
  32. ie.printStackTrace();
  33. }
  34.  
  35. finally {
  36. server.removeConnection(socket);
  37. }
  38. }
  39.  
  40.  
  41.  
  42. }
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class ServerThread is public, should be declared in a file named ServerThread.java
public class ServerThread extends Thread {
       ^
Main.java:7: error: cannot find symbol
    private Server_Side server;
            ^
  symbol:   class Server_Side
  location: class ServerThread
Main.java:10: error: cannot find symbol
    public ServerThread(Server_Side server, Socket socket){
                        ^
  symbol:   class Server_Side
  location: class ServerThread
3 errors
stdout
Standard output is empty