add thread pool
This commit is contained in:
parent
d4572677f5
commit
fda9f1d13b
Binary file not shown.
BIN
Server.class
BIN
Server.class
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
class Server {
|
||||
public static void main(String[] args) {
|
||||
|
@ -14,7 +16,8 @@ class Server {
|
|||
System.out.println("New client: " + client.getInetAddress().getHostAddress());
|
||||
|
||||
ClientHandler clientSock = new ClientHandler(client);
|
||||
new Thread(clientSock).start();
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
executorService.submit(clientSock);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue