Page 845 - 3-2
P. 845
TimerTask timeTask = new TimerTask(){
@Override
public void run() {
if(v.size()>0){ // 접속된 클라이언트가 있다면
System.out.println("cli= " + cli);
if(cli ==1) cli=0;
else
{
v.clear();
System.out.println(" 클라이언트 종료");
try {
dout.writeUTF("broken" + my);
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("v.size =" + v.size());
}
}
};
timer.schedule(timeTask, 0,4000);
t= new Thread();
str = " ";
//t.start();
SenserThread sst = new SenserThread(this);
sst.start();
//v = new Vector();
SocThread st = new SocThread(this, sock);
st.start();
/*
try { // 예외
serv = new ServerSocket(7777); // 포트번호
while(true){
sock = serv.accept(); // 클라이언트의 소켓이 올때까지 기다림
ServerThread client = new ServerThread(this, sock);
// 새로운 스레드를 생성 클라이언트하나에 하나의 스레드로 작동하기 위함,
v.addElement(client); // 저장
- 845 -