jmri.web.miniserver
Class ThreadedMiniServer

java.lang.Object
  extended by jmri.web.miniserver.NetworkServer
      extended by jmri.web.miniserver.MiniServer
          extended by jmri.web.miniserver.ThreadedMiniServer
All Implemented Interfaces:
Runnable

public class ThreadedMiniServer
extends MiniServer
implements Runnable

A multithreaded variation of MiniServer. Adapted with permission Core Web Programming from Prentice Hall and Sun Microsystems Press, http://www.corewebprogramming.com/. © 2001 Marty Hall and Larry Brown; may be freely used or adapted.

Author:
Modifications by Bob Jacobsen Copyright 2005, 2006, 2009, 2010

Field Summary
 
Fields inherited from class jmri.web.miniserver.MiniServer
maxRequestLines, serverName
 
Fields inherited from class jmri.web.miniserver.NetworkServer
port
 
Constructor Summary
ThreadedMiniServer(int port, int connections)
           
 
Method Summary
 void handleConnection(Socket server)
          The new version of handleConnection starts a thread.
 void run()
           
 
Methods inherited from class jmri.web.miniserver.MiniServer
getLocalAddress, getPort, main, pickServlet
 
Methods inherited from class jmri.web.miniserver.NetworkServer
getMaxConnections, listen, setMaxConnections, setPort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedMiniServer

public ThreadedMiniServer(int port,
                          int connections)
Method Detail

handleConnection

public void handleConnection(Socket server)
The new version of handleConnection starts a thread. This new thread will call back to the old version of handleConnection, resulting in the same server behavior in a multithreaded 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 MiniServer

run

public void run()
Specified by:
run in interface Runnable


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads