de.anneck.jcast.core
Interface IThread

All Superinterfaces:
org.apache.avalon.framework.configuration.Configurable, IStartable, java.lang.Runnable
All Known Subinterfaces:
IChannelThread, IListenerThread, IServerThread, ISourceThread
All Known Implementing Classes:
AbstractThread

public interface IThread
extends java.lang.Runnable, IStartable, org.apache.avalon.framework.configuration.Configurable

The Interface for all Threads. All JCast Threads manage their states, and need to have utility methods to access name, priority, etc. Through this interface you can interact with all threads in JCast, regarding direct thread control mechanism.

Version:
$Revision: 1.5 $
Author:
andre.anneck@web.de

Field Summary
static int RUNNING
           
static int STOPPED
          My states
static int WAITING
           
 
Method Summary
 boolean checkState(int state)
          checks the current state
 void doKill()
          Trys to kill the running thread
 void doRestart()
          Trys to restart the waiting thread
 void doStart()
          Gets the thread into running mode
 void doStop()
          Trys to stop the running thread
 void doWork()
          Executes whatever this thread is supposed to do
 java.lang.String getThreadClass()
          Returns the class by which this thread was initialized
 java.lang.String getThreadName()
          Returns the Name of the Thread
 int getThreadPriority()
          Returns threads priority
 boolean isRunning()
          Returns true if the thread is Running
 boolean isStopped()
          Returns true if the thread is stopped
 boolean isWaiting()
          Returns true if the thread is waiting for something
 void setState(int state)
          Sets the threads state
 void setThreadPriority(int i)
          Sets thread priority
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 

Field Detail

STOPPED

public static final int STOPPED
My states

RUNNING

public static final int RUNNING

WAITING

public static final int WAITING
Method Detail

getThreadName

public java.lang.String getThreadName()
Returns the Name of the Thread

getThreadClass

public java.lang.String getThreadClass()
Returns the class by which this thread was initialized

getThreadPriority

public int getThreadPriority()
Returns threads priority

setThreadPriority

public void setThreadPriority(int i)
Sets thread priority

checkState

public boolean checkState(int state)
checks the current state

setState

public void setState(int state)
Sets the threads state

isRunning

public boolean isRunning()
Returns true if the thread is Running

isStopped

public boolean isStopped()
Returns true if the thread is stopped

isWaiting

public boolean isWaiting()
Returns true if the thread is waiting for something

doStart

public void doStart()
             throws java.lang.Exception
Gets the thread into running mode
Specified by:
doStart in interface IStartable

doStop

public void doStop()
            throws java.lang.Exception
Trys to stop the running thread
Specified by:
doStop in interface IStartable

doKill

public void doKill()
Trys to kill the running thread

doRestart

public void doRestart()
               throws java.lang.Exception
Trys to restart the waiting thread

doWork

public void doWork()
            throws java.lang.Exception
Executes whatever this thread is supposed to do