com.singularsys.aa
Class ThreadControl

java.lang.Object
  extended by com.singularsys.aa.ThreadControl

public class ThreadControl
extends java.lang.Object

Controls the solver threads and maintains state information for the solver threads. (Singleton design pattern)


Constructor Summary
ThreadControl()
          Initialize isRunning[] array to false ( = no threads running)
 
Method Summary
static ThreadControl getInstance()
          Returns the single instance of this class.
static void mustStop()
          Throws an exception if the current SolverThread must stop.
static boolean mustStop(int threadIndex)
          Returns true if the thread identified by threadIndex must stop.
static void notifyTerminated(int threadIndex)
          Each thread must call this method immediately before it terminates so that it's threadIndex number is freed up, and can be reused for a new thread.
static void startNewThread(SolverListener listener, java.lang.String eqText)
          Starts a new instance of SolverThead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadControl

public ThreadControl()
Initialize isRunning[] array to false ( = no threads running)

Method Detail

getInstance

public static ThreadControl getInstance()
Returns the single instance of this class.


startNewThread

public static void startNewThread(SolverListener listener,
                                  java.lang.String eqText)
                           throws java.lang.Exception
Starts a new instance of SolverThead. First determine new index number for the new thread. Ensure we are not reusing a number of a running thread, and the index number is not over MAX_INDEX.

Throws an exception if all possible thread index numbers are already being used.

Throws:
java.lang.Exception

mustStop

public static boolean mustStop(int threadIndex)
Returns true if the thread identified by threadIndex must stop.


mustStop

public static void mustStop()
                     throws java.lang.Exception
Throws an exception if the current SolverThread must stop. Does nothing if the current thread is not a SolverThread.

Throws:
java.lang.Exception

notifyTerminated

public static void notifyTerminated(int threadIndex)
Each thread must call this method immediately before it terminates so that it's threadIndex number is freed up, and can be reused for a new thread.