javatools.cron
Class CronThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--javatools.cron.CronThread
All Implemented Interfaces:
java.lang.Runnable, Server

public class CronThread
extends java.lang.Thread
implements Server

Crontab uses this class as its method for executing a process. ThreadGroup is the threadgroup to execute this thread in. Since Crontab will execute everything in the one ThreadGroup this provides a method for getting all the processes that are active if so desired. The class to be executed can be in one of two forms. First thing we check is if the class has a static main method. If so it is executed and the arguments are passed to main. If there is no main() we check that the class implements Runnable. If so we create an instance and pass the args to the constructor. If the constructor doesn't accept arguments we call the default constructor and the arguments are lost. If the class has no main() and is not Runnable, then then a class cast exception is thrown.

Should you wish your threads to be executed at a different priority, feel free to have your tasks accept one of the arguments to be the priority and call Thread.currentThread().setPriority(). If you would like a standard handling of this, feel free to inherit CrontabEntry and override execute() to, for example, have the first argument always be the priority. I don't want to set a policy for this. I'll let the users do that.


Field Summary
(package private)  java.lang.String[] args
           
(package private)  java.lang.String className
           
(package private)  java.lang.Runnable runnable
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CronThread(java.lang.ThreadGroup threadGroup, java.lang.String className, java.lang.String[] args)
           
 
Method Summary
 void error(java.lang.Throwable t)
           
 void run()
           
 void shutdown()
          Shutdown this server thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

args

java.lang.String[] args

className

java.lang.String className

runnable

java.lang.Runnable runnable
Constructor Detail

CronThread

public CronThread(java.lang.ThreadGroup threadGroup,
                  java.lang.String className,
                  java.lang.String[] args)
Parameters:
threadGroup - group that this thread will belong to
className - class to execute
args - arguments to pass to the class.
Method Detail

shutdown

public void shutdown()
Description copied from interface: Server
Shutdown this server thread.

Specified by:
shutdown in interface Server

run

public final void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

error

public void error(java.lang.Throwable t)