📄 receiverthread.java
字号:
package test;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.SocketException;
public class ReceiverThread extends Thread{// 信息接收线程
DataInputStream input; // 定义输入流
String msg = "";
public ReceiverThread(DataInputStream input1) throws SocketException {
input = input1;
}
public void run() {
byte[] buffer = new byte[65507];
while (true) {
try {
msg = input.readUTF(); // 接收服务器应答信息
if(msg.equalsIgnoreCase("you want add user")){
//Thread thread = new Thread();
//thread.interrupt();
}
System.out.println(" Server: " + msg); // 显示收到的信息
}
catch (IOException e) {
System.out.println("Server closed!");
try {
Thread.sleep(2000);
}
catch (InterruptedException ex) {}
System.exit(1);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -