edu.cornell.cs.sam.utils
Class SamThread

java.lang.Object
  extended by java.lang.Thread
      extended by edu.cornell.cs.sam.utils.SamThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
SamGUI.RunThread, TestScript.TestThread

public abstract class SamThread
extends java.lang.Thread

The base class for threads in SaM GUIs. It implements the basics that all such threads responsible for running code need


Nested Class Summary
static interface SamThread.ThreadParent
          The parent of a thread
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int THREAD_EXCEPTION
          A thread status indication there was an exception in the thread
static int THREAD_EXIT_OK
          A thread status indication successful completion
static int THREAD_INTERRUPTED
          A thread status indicating that the thread has been interrupted
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SamThread()
           
 
Method Summary
 void clearInterrupt()
          Removes the interrupt flag
abstract  void execute()
          The main method used to execute one step.
 SamThread.ThreadParent getParent()
          Returns the thread parent
 void interrupt()
          Interrupts the thread
 boolean interruptRequested()
          Check if an interrupt has been requested
 void run()
          Initiates thread execution.
 void setParent(SamThread.ThreadParent parent)
          Sets the parent to the provided parent param parent The parent to set
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THREAD_INTERRUPTED

public static final int THREAD_INTERRUPTED
A thread status indicating that the thread has been interrupted

See Also:
Constant Field Values

THREAD_EXCEPTION

public static final int THREAD_EXCEPTION
A thread status indication there was an exception in the thread

See Also:
Constant Field Values

THREAD_EXIT_OK

public static final int THREAD_EXIT_OK
A thread status indication successful completion

See Also:
Constant Field Values
Constructor Detail

SamThread

public SamThread()
Method Detail

setParent

public void setParent(SamThread.ThreadParent parent)
Sets the parent to the provided parent param parent The parent to set


getParent

public SamThread.ThreadParent getParent()
Returns the thread parent

Returns:
the parent of this thread

interrupt

public void interrupt()
Interrupts the thread

Overrides:
interrupt in class java.lang.Thread

interruptRequested

public boolean interruptRequested()
Check if an interrupt has been requested

Returns:
true if an interrupt was requested, false otherwise

clearInterrupt

public void clearInterrupt()
Removes the interrupt flag


run

public void run()
Initiates thread execution.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

execute

public abstract void execute()
                      throws java.lang.Exception
The main method used to execute one step. This method must check the stopRequested flag and respect its status.

Throws:
java.lang.Exception