uk.ac.ic.doc.automed.util.thread
Class TimedThread

java.lang.Object
  extended by java.lang.Thread
      extended by uk.ac.ic.doc.automed.util.thread.TimedThread
All Implemented Interfaces:
java.lang.Runnable

public class TimedThread
extends java.lang.Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean _daemon
           
private  int _id
           
private  java.lang.String _name
           
private  long _sleepTime
           
private  boolean _stop
           
private  Threadable _threadableObj
           
private static boolean debugError
           
private static int ID_COUNTER
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimedThread(long sleepTime, Threadable threadableObj, boolean daemon)
          An overloading constructor for instant running of a thread object
TimedThread(java.lang.String name, int id, long sleepTime, Threadable threadableObj, boolean daemon)
          Creates a new instance of TimedThread
TimedThread(java.lang.String name, long sleepTime, Threadable threadableObj, boolean daemon)
          An overloading constructor for instant running of a thread object
TimedThread(Threadable threadableObj, boolean daemon)
          An overloading constructor for instant running of a thread object
 
Method Summary
static java.lang.String getDefaultName()
          Return the default, unique name for a thread
static int getNextID()
          Get the next id counter for a new thread
 boolean getReadyState()
          Get the state of the handler object (ready or note).
 Threadable getThreadObject()
          Return the threadable object
 boolean isStopped()
          Check if a thread is started or not
 void restartThread()
          To restart, stop and start it
 void run()
          Implements the thread-running method
 void startThread()
          Start (rather resume) a thread's operation
 void stopThread()
          Stop (rather pause) a thread
 
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, interrupt, 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

_name

private java.lang.String _name

_id

private int _id

_sleepTime

private long _sleepTime

_threadableObj

private Threadable _threadableObj

_daemon

private boolean _daemon

_stop

private boolean _stop

ID_COUNTER

private static int ID_COUNTER

debugError

private static final boolean debugError
Constructor Detail

TimedThread

public TimedThread(java.lang.String name,
                   int id,
                   long sleepTime,
                   Threadable threadableObj,
                   boolean daemon)
Creates a new instance of TimedThread

Parameters:
name - a meaningful name for thread object
id - a unique thread's id
sleepTime - a sleep time in seconds
threadableObj - a thread-handling object
daemon - whether or not to create a daemon-like thread

TimedThread

public TimedThread(java.lang.String name,
                   long sleepTime,
                   Threadable threadableObj,
                   boolean daemon)
An overloading constructor for instant running of a thread object


TimedThread

public TimedThread(long sleepTime,
                   Threadable threadableObj,
                   boolean daemon)
An overloading constructor for instant running of a thread object


TimedThread

public TimedThread(Threadable threadableObj,
                   boolean daemon)
An overloading constructor for instant running of a thread object

Method Detail

stopThread

public void stopThread()
Stop (rather pause) a thread


startThread

public void startThread()
Start (rather resume) a thread's operation


isStopped

public boolean isStopped()
Check if a thread is started or not


restartThread

public void restartThread()
To restart, stop and start it


getReadyState

public boolean getReadyState()
Get the state of the handler object (ready or note). This is especially useful
for server thread.


run

public void run()
Implements the thread-running method

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

getDefaultName

public static java.lang.String getDefaultName()
Return the default, unique name for a thread

Returns:
String default thread's name

getThreadObject

public Threadable getThreadObject()
Return the threadable object


getNextID

public static int getNextID()
Get the next id counter for a new thread

Returns:
int next thread's id