public class ServerThread extends Thread { private int port; public ServerThread(int port) { this.port = port; }
private boolean stop = false;
public void run() { try { ServerSocket server = new ServerSocket(port); while (!stop) { Socket client = server.accept(); BufferedReader read = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter streamWriter = new PrintWriter(client.getOutputStream());//關鍵是這裡 System.out.println("發送歡迎資訊");