/Users/lyon/j4p/src/net/compute/ReloadServer.java
|
1 package net.compute;
2
3 import java.io.IOException;
4 import java.net.ServerSocket;
5 import java.net.Socket;
6
7
8 public class ReloadServer implements Runnable {
9 public static final int PORT = 8088;
10 public static void main(String args[]) {
11 Thread serverThread = new Thread(
12 new ReloadServer());
13 serverThread.start();
14 try {
15 Thread.sleep(1000);
16 } catch (InterruptedException e) {
17 }
18 }
19
20 public void run() {
21 try {
22 ServerSocket ss =
23 new ServerSocket(PORT);
24 while (true) {
25 System.out.println("waiting");
26 // block the primary thread of execution
27 // during the accept invocation
28 Socket socket = ss.accept();
29 // use socket to get a computable object
30 // do the computation and return the result.
31 ReloadThread ct =
32 new ReloadThread(socket);
33 ct.start();
34
35 }
36 } catch (IOException e) {
37 e.printStackTrace();
38 }
39 }
40 }
41