org.mitre.midiki.workshop
Class ThreadedDiseaseServer

java.lang.Object
  |
  +--org.mitre.midiki.workshop.NetworkServer
        |
        +--org.mitre.midiki.workshop.DiseaseServer
              |
              +--org.mitre.midiki.workshop.ThreadedDiseaseServer
All Implemented Interfaces:
java.lang.Runnable

public class ThreadedDiseaseServer
extends DiseaseServer
implements java.lang.Runnable

A multi-threaded variation of DiseaseServer.
Adapted from code that appears in Core Web Programming from Prentice Hall Publishers, and may be freely used or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

Since:
1.0
See Also:
DiseaseServer, Runnable

Fields inherited from class org.mitre.midiki.workshop.DiseaseServer
buffer, cvtbuf, defaultDatabaseName, defaultDTD, dtdData, id, maxInputLines, nextId, serverName, uc, wd
 
Fields inherited from class org.mitre.midiki.workshop.NetworkServer
maxConnections, port
 
Constructor Summary
ThreadedDiseaseServer(int port, int connections)
           
 
Method Summary
 void handleConnection(java.net.Socket server)
          The new version of handleConnection starts a thread.
static void main(java.lang.String[] args)
          Supply a port number as a command-line argument.
 void run()
           
 
Methods inherited from class org.mitre.midiki.workshop.DiseaseServer
containsIgnoreCase, fromUrl, loadDatabase, loadDTD, parseCommand, parseHistory, parseSymptom, parseTest, toUrl
 
Methods inherited from class org.mitre.midiki.workshop.NetworkServer
listen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedDiseaseServer

public ThreadedDiseaseServer(int port,
                             int connections)
Method Detail

main

public static void main(java.lang.String[] args)
Description copied from class: DiseaseServer
Supply a port number as a command-line argument. Otherwise port 5555 will be used.

handleConnection

public void handleConnection(java.net.Socket server)
The new version of handleConnection starts a thread. This new thread will call back to the old version of handleConnection, keeping the same server behavior in a multi-threaded version. The thread stores the Socket instance since run doesn't take any arguments, and since storing the socket in an instance variable risks having it overwritten if the next thread starts before the run method gets a chance to copy the socket reference.
Overrides:
handleConnection in class DiseaseServer

run

public void run()
Specified by:
run in interface java.lang.Runnable