org.ourgrid.test.threadServices
Class ShutdownableThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.ourgrid.test.threadServices.ShutdownableThread
All Implemented Interfaces:
java.lang.Runnable, Shutdownable

public class ShutdownableThread
extends java.lang.Thread
implements Shutdownable

This class is used just to test the auxiliary classes used by the aspects.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int DEAD
          A Thread that has leaved the run method.
static boolean DEBUG
          A DEBUG constant.
static int NEW
          A Thread that has been created.
static int NOT_CREATED
          A constant used to represent a Thread not yet created.
static int NOT_RUNNABLE
          A thread is NOT_RUNNABLE when:
* Its sleep method is invoked.
* The thread calls the wait method to wait for a specific condition to be satisfied.
static int NOT_RUNNABLE_SLEEP
          The thread has called the sleep method.
static int NOT_RUNNABLE_WAIT
          The thread calls the wait method to wait for a specific condition to be satisfied.
static int POSSIBLY_NOTIFIED
          A notify method has been called on an object whose lock was waited by this thread.
static int RUNNING
          A Thread that has entered the run method and has not yet left it.
static int STARTED
          The Thread has been created and a start method has been called on it.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ShutdownableThread(java.lang.Runnable target)
          Constructor.
ShutdownableThread(java.lang.Runnable target, java.lang.String name)
          Constructor.
ShutdownableThread(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
          Constructor.
 
Method Summary
 java.lang.Runnable getMyRunnable()
          Gets the myRunnable object.
 java.lang.String getStateString()
          Returns the textual representation of this Thread state.
static java.lang.String getStateString(int state)
          Gets the string representation of a certain state.
 int getStateValue()
          Gets the state of a this Thread.
 void println(java.lang.String str)
          General method that prints the string parameter on the standard output.
 void run()
          Simply calls the super class run method, changing this thread state before and after this.
protected  void setState(int state)
          Sets the state of this Thread.
 void shutdown()
          Invokes shutdown on this thread's runnable, if it is Shutdownable.
 void start()
          Starts this Thread, changing its state.
 void waitFor(java.lang.Object o)
          Makes this thread wait for an object.
 
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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
A DEBUG constant.

See Also:
Constant Field Values

NOT_CREATED

public static final int NOT_CREATED
A constant used to represent a Thread not yet created.

See Also:
Constant Field Values

NEW

public static final int NEW
A Thread that has been created. (Entered the constructor) The isAlive() method from Thread returns true, if it is in this state and also when the thread is DEAD.

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
A Thread that has entered the run method and has not yet left it. For some situations described in the other states, the thread can stop running for some time.

See Also:
Constant Field Values

STARTED

public static final int STARTED
The Thread has been created and a start method has been called on it.

See Also:
Constant Field Values

DEAD

public static final int DEAD
A Thread that has leaved the run method. The isAlive() method from Thread returns true, if it is in this state and also when the thread is NEW.

See Also:
Constant Field Values

NOT_RUNNABLE

public static final int NOT_RUNNABLE
A thread is NOT_RUNNABLE when:
* Its sleep method is invoked.
* The thread calls the wait method to wait for a specific condition to be satisfied.
* The thread is blocking on I/O.
This variable will be used when we cannot indicate any of these or when the difference between them does not matter to the application.

See Also:
Constant Field Values

NOT_RUNNABLE_WAIT

public static final int NOT_RUNNABLE_WAIT
The thread calls the wait method to wait for a specific condition to be satisfied. After this call to wait returns, this thread will be probably running.

See Also:
Constant Field Values

NOT_RUNNABLE_SLEEP

public static final int NOT_RUNNABLE_SLEEP
The thread has called the sleep method. After this call returns, the thread will be running.

See Also:
Constant Field Values

POSSIBLY_NOTIFIED

public static final int POSSIBLY_NOTIFIED
A notify method has been called on an object whose lock was waited by this thread. However, we are not sure if this thread will run now.

See Also:
Constant Field Values
Constructor Detail

ShutdownableThread

public ShutdownableThread(java.lang.Runnable target)
Constructor.

Parameters:
target - The Runnable related with this Thread.

ShutdownableThread

public ShutdownableThread(java.lang.Runnable target,
                          java.lang.String name)
Constructor.

Parameters:
target - The Runnable related with this Thread.
name - The Thread name.

ShutdownableThread

public ShutdownableThread(java.lang.ThreadGroup group,
                          java.lang.Runnable target,
                          java.lang.String name)
Constructor.

Parameters:
group - The Thread group.
target - The Runnable related with this thread.
name - The Thread name.
Method Detail

shutdown

public void shutdown()
Invokes shutdown on this thread's runnable, if it is Shutdownable.

Specified by:
shutdown in interface Shutdownable

getStateString

public java.lang.String getStateString()
Returns the textual representation of this Thread state.

Returns:
a String representing the thread state, followed by the code of the state. If there is not a string representation for the code, just its code is returned.

getStateString

public static java.lang.String getStateString(int state)
Gets the string representation of a certain state.

Parameters:
state - The state value.
Returns:
a string representing state.

start

public void start()
Starts this Thread, changing its state.

Overrides:
start in class java.lang.Thread

waitFor

public void waitFor(java.lang.Object o)
             throws java.lang.InterruptedException
Makes this thread wait for an object.

Parameters:
o - The object this thread should wait for.
Throws:
java.lang.InterruptedException

run

public void run()
Simply calls the super class run method, changing this thread state before and after this.

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

getStateValue

public int getStateValue()
Gets the state of a this Thread.

Returns:
Returns the state of a this Thread.

setState

protected void setState(int state)
Sets the state of this Thread.

Parameters:
state - The state to set.

getMyRunnable

public java.lang.Runnable getMyRunnable()
Gets the myRunnable object.

Returns:
Returns the myRunnable object.

println

public void println(java.lang.String str)
General method that prints the string parameter on the standard output.

Parameters:
str - String to be printed.