comparison src/goodjava/webserver/Server.java @ 1502:8a7b6b32c691

minor threads
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 10 May 2020 22:48:15 -0600
parents 27efb1fcbcb5
children
comparison
equal deleted inserted replaced
1501:e66e3d50b289 1502:8a7b6b32c691
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.net.Socket; 4 import java.net.Socket;
5 import java.net.ServerSocket; 5 import java.net.ServerSocket;
6 import java.net.InetAddress; 6 import java.net.InetAddress;
7 import java.net.UnknownHostException; 7 import java.net.UnknownHostException;
8 import java.util.concurrent.ThreadPoolExecutor;
9 import java.util.concurrent.Executors; 8 import java.util.concurrent.Executors;
9 import java.util.concurrent.ExecutorService;
10 import java.util.concurrent.TimeUnit; 10 import java.util.concurrent.TimeUnit;
11 import goodjava.logging.Logger; 11 import goodjava.logging.Logger;
12 import goodjava.logging.LoggerFactory; 12 import goodjava.logging.LoggerFactory;
13 13
14 14
15 public class Server { 15 public class Server {
16 private static final Logger logger = LoggerFactory.getLogger(Server.class); 16 private static final Logger logger = LoggerFactory.getLogger(Server.class);
17 17
18 public final int port; 18 public final int port;
19 public final Handler handler; 19 public final Handler handler;
20 public static final ThreadPoolExecutor threadPool = (ThreadPoolExecutor)Executors.newCachedThreadPool(); 20 public static final ExecutorService threadPool = Executors.newCachedThreadPool();
21 21
22 public Server(int port,Handler handler) { 22 public Server(int port,Handler handler) {
23 this.port = port; 23 this.port = port;
24 this.handler = handler; 24 this.handler = handler;
25 } 25 }