※ 为什么循环不能继续?

J_2004 J_2004 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
while (it.hasNext()){
key = it.next();
try{
cc = (ChatClient)chatClients.get(key);
cc.sendln(str);
}catch(Exception e){
//e.printStackTrace();
try {
cc.close();
} catch (Exception e1) {
e1.printStackTrace();

}
chatClients.remove(key);
continue;
}

}

---------
运行以上代码,当发生异常时,循环就退出了。已经捕获异常,并处理了,为什么循环不能继续?
*异常是这个方法抛出的: cc.sendln(str) -> writer.write(s);writer是用socket输出流构造的OutputStreamWriter对象;writer = new OutputStreamWriter(socket.getOutputStream());

...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
J_2004
Java SE 62,620 成员 307,251 内容