
144 // close client connection
145 try
146 {
147 clnt.close();
148 clnt = null ;
149 }
150 catch (IOException ioe)
151 {
152 System.err.println(“IOException: “
153 + ioe.getMessage());
154 }
155 }
156
157
// be nice to CPU
158 try
159 {
160 Thread.sleep(10);
161 }
162 catch(InterruptedException ie)
163 {
164 }
165
166
// continue monitoring queue..
167 }
168 }
169 }
Compilation
C:\> j2sdk1.4.1_02\bin\javac.exe WormCatcher.java
C:\> dir
.
.
ThreadPool.class
WorkerThread.class
WormCatcher.class
.
.
Example Execution
C:\> j2sdk1.4.1_02\bin\java.exe WormCatcher
usage: java WormCatcher <local_port>
Example: java WormCatcher 80
C:\> j2sdk1.4.1_02\bin\java.exe WormCatcher 80
*** WorkerThread ...