主进程函数
public static void main(String[] args) {
System.out.println("hello world");
JFrame a=new JFrame("");
ExecutorService executorService = Executors.newFixedThreadPool(5);
Runnable socketThread=new Runnable(){
@Override
public void run() {
try {
// 创建服务端socket
ServerSocket serverSocket = new ServerSocket(8088);
logger.info("listen:8088");
Thread thread1=new Thread() {
public void run() {
Socket socket ;
//循环监听等待客户端的连接
while(true){
try {
socket = serverSocket.accept();
// 监听客户端
InetAddress address=socket.getInetAddress();
System.out.println("当前客户端的IP:"+address.getHostAddress());
ServerThread3 thread = new ServerThread3(socket,a);
// thread.start();
executorService.submit(thread);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// thread.run();
}
}
};
thread1.start();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
};
try {
SwingUtilities.invokeLater(socketThread);
} catch (Exception e1) {
e1.printStackTrace();
}
}