org.zaval.util
Class Timer
java.lang.Object
|
+--java.lang.Thread
|
+--org.zaval.util.Timer
- All Implemented Interfaces:
- java.lang.Runnable
- public class Timer
- extends java.lang.Thread
This is timer component. The class is used to organize periodic execution for the
registered Runnable interfaces. The class contains getTimer static method
to get the Timer instance. Using the method you can get shared timer instance or own
(new) timer instance. Shared instance can be used by several consumers.
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
|
Method Summary |
void |
add(java.lang.Runnable l,
int startIn,
int repeatIn)
Adds the specified runnable interface to be executed in the given time with the specified
period. |
void |
clear(java.lang.Runnable l)
Clears tick counter for the specified runnable interface. |
static Timer |
getTimer(boolean b)
Gets a timer instance. |
void |
remove(java.lang.Runnable l)
Removes the specified runnable interface so it no longer to be executed. |
void |
run()
This is timer thread body method that executes all registered workers in the certain
period of time. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, 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 |
add
public void add(java.lang.Runnable l,
int startIn,
int repeatIn)
- Adds the specified runnable interface to be executed in the given time with the specified
period.
- Parameters:
l - the specified runnable interface.startIn - the specified time (milliseconds) after that the interface will
be executed first.repeatIn - the specified period (milliseconds) of the runnable interface
execution.
remove
public void remove(java.lang.Runnable l)
- Removes the specified runnable interface so it no longer to be executed.
- Parameters:
l - the specified runnable interface.
clear
public void clear(java.lang.Runnable l)
- Clears tick counter for the specified runnable interface. The method allows
you to put off the runnable interface executing.
- Parameters:
l - the specified runnable interface.
run
public void run()
- This is timer thread body method that executes all registered workers in the certain
period of time.
- Overrides:
run in class java.lang.Thread
getTimer
public static Timer getTimer(boolean b)
- Gets a timer instance. The specified flag indicates if the timer instance should be created
or not.
- Parameters:
b - the specified flag. If the parameter is true than
a new timer instance will be created otherwise shared timer instance will be returned.- Returns:
- the timer instance.
|