public class Server {
ServerSocket
serverSocket;
// reading from
port
static int
port = 6500;
static int
delay = 10;
// Sleep time /
Request (ms)
static int
spin = 10;
// CPU-spin time (us)
static boolean
DEBUG = false;
static int
nConsumers = 10;
static int
MAX_LENGTH = 10;
// Max length of
Workpile
static int
MAX_OPEN = 1000;
// Max open file
descriptors
static int
outstandingClients = 0;
static Workpile
workpile;
static Thread[]
consumers;
static Thread[]
producers;
static int
nProducers=0;
// # active clients
static int
stopperTimeout = 10;
// 10s
static int
killerTimeout = 120;
// 2min
static boolean
KILL = false;
static Thread
acceptor;
// Thread doing
accept()
public static void main(String[] args) {
Server server = new Server();
if (args.length > 0)
port = Integer.parseInt(args[0]);
if (args.length > 1)
delay = Integer.parseInt(args[1]);
if (args.length > 2)
spin = Integer.parseInt(args[2]);
if (args.length > 3)
nConsumers = Integer.parseInt(args[3]);
if (args.length > 4)
stopperTimeout = Integer.parseInt(args[4]);
if (args.length > 5)
killerTimeout = Integer.parseInt(args[5]);
if (System.getProperty("DEBUG") != null)
DEBUG = true;
if (System.getProperty("KILL") != null)
KILL = true;
System.out.println("Server(port: " + port + " delay: " +
delay + "ms spin: " + spin + "us nConsumers: " +
nConsumers + " stopperTimeout " + stopperTimeout +
"s killerTimeout " + killerTimeout + "s)");
server.runServer();
}
public void runServer() { // Executes in main thread
Socket socket;
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home