日期:2014-05-18 浏览次数:20683 次
try{
ServerSocket srvSocket=new ServerSocket(“7013”);
ThreadPoolTaskExecutor pe=null;
while(true){
Socket socket=srvSocket.accept();
socket.setKeepAlive(true); //这个keepAlive是为了检测已经死掉的socket(检测周期大概2小时)
ServerHandler serverHandler=new ServerHandler(socket);
if(pe!=null){
pe.execute(serverHandler);
}else{
pe = (ThreadPoolTaskExecutor)POSPComponentFactory.getComponent("taskExecutor");
pe.execute(serverHandler);
}
}
}catch(Exception e){
e.printStackTrace();
} finally{
close();
}