if(source==t.btnSend)
{ out.println(t.getTalk());
t.clearTalk();
}else
if(source==t.btnEnd)
{ out.println("谈话过程被对方终止");
out.close();
in.close();
talking = false;
}
}catch(IOException ex){
}
}
public void run()
{ try{
t=new talkServerFrm(new Integer(threadNum).toString(),this);
t.setSize(500,500);
t.show();
in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(),true);
}catch(Exception e){
}
new Thread()
{ public void run()
{ try{
while(true)
{ checkInput();
sleep(1000);
}
}catch (InterruptedException ex){
}catch(IOException ex){
}
}
}.start();
while(talking)
{ }
t.dispose();
}
private void checkInput() throws IOException
{ String line;
if((line=in.readLine())!=null)
t.setPartner(line); file://这是界面类里的方法,
file://用来将line的内容输出到用户界面
}
}