public void run() {
try {
final ObjectInputStream ois = new ObjectInputStream(mClient.getInputStream());
while (true) {
final LoggingEvent event = (LoggingEvent) ois.readObject();
mModel.addEvent(new EventDetails(event));
} // 这里为什么对输入流 循环读取object,mClient是Scoket
} catch (EOFException e) {
LOG.info("Reached EOF, closing connection");
}
try {
mClient.close();
} catch (IOException e) {
LOG.warn("Error closing connection", e);
}
}
这不是很正常么. 一个(或者N个)线程网络线程获取到对象, push到消息队列里面去, 让主循环去消费处理.