no.ntnu.vegare.visualizer.server.background
Class ThreadPool

java.lang.Object
  extended by no.ntnu.vegare.visualizer.server.background.ThreadPool

public class ThreadPool
extends java.lang.Object

Thread safe singleton implementation by Bill Pugh: http://en.wikipedia.org/wiki/Singleton_pattern

Holds all background threads in the application, and verifies that these are not interfering with each other.

Author:
vegare

Method Summary
static ThreadPool getInstance()
           
 java.lang.String startGenerator(LogDatabase db, int perHour)
          Start a generator thread, creating random incidents.
 java.lang.String startServer(LogDatabase db, int port, java.lang.Thread.UncaughtExceptionHandler eh)
          Start a new HTTP server on a specified port.
 java.lang.String stopGenerator()
          Stop the generator thread from executing.
 java.lang.String stopServer()
          Stop the server from executing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ThreadPool getInstance()

startServer

public java.lang.String startServer(LogDatabase db,
                                    int port,
                                    java.lang.Thread.UncaughtExceptionHandler eh)
Start a new HTTP server on a specified port.

Parameters:
db - Database containing target incidents
port - TCP port to run HTTP server on
eh - An UncaughtExceptionHandler which receives unexpected errors.
Returns:
"OK" if server was started, error msg if an exception occurred.

stopServer

public java.lang.String stopServer()
Stop the server from executing.

Returns:
Always "OK" in the prototype.

startGenerator

public java.lang.String startGenerator(LogDatabase db,
                                       int perHour)
Start a generator thread, creating random incidents.

Parameters:
db - Database to load incidents into
perHour - Average incidents per hour
Returns:
Always "OK" in the prototype.

stopGenerator

public java.lang.String stopGenerator()
Stop the generator thread from executing.

Returns:
"OK" on success, otherwise error message