-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.java
34 lines (27 loc) · 1015 Bytes
/
Server.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package servers;
import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingQueue;
public class Server
{
private static final int DEFAULT_PORT = 4;
private static final int DEFAULT_BACKLOG = 10;
private int port;
private int backlog;
private ArrayList<ClientConnection> clientConnectionList;
private LinkedBlockingQueue<String> clientMessageList;
public Server(int port, int backlog) {
this.port = port;
this.backlog = backlog;
clientConnectionList = new ArrayList<ClientConnection>();
clientMessageList = new LinkedBlockingQueue<String>();
}
public void start()
{
new Thread ( new ServerListener(port, backlog, clientConnectionList, clientMessageList) ).start();
new Thread( new ServerSender(clientConnectionList, clientMessageList) ).start();
}
public static void main(String[] Args) {
Server server = new Server(Server.DEFAULT_PORT, Server.DEFAULT_BACKLOG);
server.start();
}
}