irssibot.util
Class Timer

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--irssibot.util.Timer
All Implemented Interfaces:
java.lang.Runnable

public class Timer
extends java.lang.Thread

A generic timer. The timer is deployed as its own thread with a given number of seconds and a TimerCommand object reference. After the timer period, the execute() method of the TimerCommand object is invoked.

Version:
$Name: $ $Revision: 1.3 $
Author:
Matti Dahlbom

Field Summary
private  TimerCommand command
          TimerCommand to execute
private  boolean isRunning
          Indicates whether this timer is still alive
private  int period
          Wait period
private  java.lang.Object waitLock
          Wait lock
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private Timer(int period, TimerCommand command)
          Inits the timer.
 
Method Summary
static Timer deploy(int period, TimerCommand command)
          Deploys a Timer with given wait period and command object.
 void killTimer()
          Kills this timer, ending the wait.
 void run()
          Performs the actual wait / execute invokation.
 
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

isRunning

private boolean isRunning
Indicates whether this timer is still alive


waitLock

private java.lang.Object waitLock
Wait lock


period

private int period
Wait period


command

private TimerCommand command
TimerCommand to execute

Constructor Detail

Timer

private Timer(int period,
              TimerCommand command)
Inits the timer.

Parameters:
period - number of seconds to wait before executing command
command - object whose execute() method to call after given period
Method Detail

deploy

public static Timer deploy(int period,
                           TimerCommand command)
Deploys a Timer with given wait period and command object. After period seconds have passed, call the execute() method of the command object.

Parameters:
period - number of seconds to wait before executing command
command - object whose execute() method to call after given period
Throws:
java.lang.IllegalArgumentException - if period is out of range or command parameter is null

run

public void run()
Performs the actual wait / execute invokation.

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

killTimer

public void killTimer()
Kills this timer, ending the wait.



IrssiBot (c) 2000-2002 Matti Dahlbom