我有一个线程可以从 ObjectInputStream 中读取对象:
public void run() {
try {
ois = new ObjectInputStream(clientSocket.getInputStream());
Object o;
while ((o = ois.readObject()) != null) {
//do something with object
}
} catch (Exception ex) {
//Log exception
}
}
readObject 不会抛出 InterruptedException 并且据我所知,当该线程被中断时不会抛出异常。我如何停止这个线程?