org.elite.jdcbot.util
Class TimerThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.elite.jdcbot.util.TimerThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FloodMessageThread

public abstract class TimerThread
extends java.lang.Thread

Simple abstract class for generating OnTimer event. You are encouraged to extends this thread with your own class (example is FloodMessageThread) since it enables you to have more than one onTimer event. So you would have one class which prints users joined hub on every hour on main chat and another that prints current weather on every two hours.

Since:
0.5
Version:
0.7
Author:
Kokanovic Branko, AppleGrew

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  jDCBot _bot
           
private  long _startup_wait_time
           
private  long _wait_time
           
private  boolean running
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimerThread(jDCBot bot, long wait_time, java.lang.String ThreadName)
          Constructs new thread that triggers onTimer event.
TimerThread(jDCBot bot, long wait_time, java.lang.String ThreadName, long startup_wait_time)
           
 
Method Summary
protected  void onTimer()
          Called every wait_time
protected  void onTimerStart()
           
 void run()
           
 void stopIt()
          Stops the 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

_wait_time

private long _wait_time

_startup_wait_time

private long _startup_wait_time

_bot

protected jDCBot _bot

running

private volatile boolean running
Constructor Detail

TimerThread

public TimerThread(jDCBot bot,
                   long wait_time,
                   java.lang.String ThreadName)
Constructs new thread that triggers onTimer event.

Parameters:
bot - jDCBot instance needed to send messages...
wait_time - Time (in ms) between triggers.

TimerThread

public TimerThread(jDCBot bot,
                   long wait_time,
                   java.lang.String ThreadName,
                   long startup_wait_time)
Method Detail

run

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

onTimer

protected void onTimer()
Called every wait_time

The implementation of this method in the TimerThread abstract class performs no actions and may be overridden as required.


onTimerStart

protected void onTimerStart()

stopIt

public void stopIt()
Stops the thread.