第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

求大神幫忙!?。£P(guān)于java問題

求大神幫忙?。?!關(guān)于java問題

ZXJ03 2016-12-11 18:00:07
ChatHandler.java package?pro4; import?java.net.*; import?java.io.*; import?java.util.*; public?class?ChatHandler?implements?Runnable{ ????protected?Socket?socket; ????protected?ObjectInputStream?dataIn; ????protected?ObjectOutputStream?dataOut; ????protected?Thread?listener; ????protected?static?Vector?handlers=new?Vector(); ????? ????private?boolean?keepListening=true; ????public?ChatHandler(Socket?socket){ ????????this.socket=socket; ????} ????public?synchronized?void?start(){ ????????if(listener==null){ ????????????try{ ????????????????dataIn=new?ObjectInputStream(socket.getInputStream()); ????????????????dataOut=new?ObjectOutputStream(socket.getOutputStream()); ????????????????listener=new?Thread(this); ????????????????listener.start(); ????????????}catch(IOException?ioException){ ????????????????ioException.printStackTrace(); ????????????} ????????} ????} ????public?synchronized?void?stop(){ ????????if(listener!=null){ ????????????try{ ????????????????if(listener!=Thread.currentThread()) ????????????????????listener.interrupt(); ????????????????listener=null; ????????????????dataOut.close(); ????????????????socket.close(); ????????????}catch(IOException?ignored){ ????????????????? ????????????} ????????} ????} ????public?void?run(){ ????????String?message=""; ????????try{ ????????????handlers.addElement(this); ????????????while(keepListening){ ????????????????message=(String)dataIn.readObject(); ????????????????if(message.equals("DISCONNECT")){ ????????????????????dataOut.writeObject(message); ????????????????????dataOut.flush(); ????????????????????stopListening(); ????????????????}else ????????????????????broadcast(message); ????????????} ????????}catch(ClassNotFoundException?classNotFoundException){ ????????????? ????????}catch(EOFException?ignored){ ????????????? ????????}catch(IOException?ex){ ????????????if(listener==Thread.currentThread()) ????????????????ex.printStackTrace(); ????????}finally{ ????????????handlers.removeElement(this); ????????} ????????try{ ????????????dataIn.close(); ????????}catch(IOException?ioException){ ????????????ioException.printStackTrace(); ????????} ????????stop(); ????} ????protected?void?broadcast(String?message){ ????????synchronized?(handlers){ ????????????Enumeration?enumer=handlers.elements(); ????????????while(enumer.hasMoreElements()){ ????????????????ChatHandler?handler=(ChatHandler)enumer.nextElement(); ????????????????try{ ????????????????????handler.dataOut.writeObject(message); ????????????????????handler.dataOut.flush(); ????????????????}catch(IOException?ex){ ????????????????????handler.stop(); ????????????????}?????????????? ????????????} ????????} ????} ????public?void?stopListening(){ ????????keepListening=false; ????} } 可以解釋一下run()方法和broadcast()方法嗎?看不懂,,,
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 1437 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)