com.calitha.util
Class CleanupThread
java.lang.Object
java.lang.Thread
com.calitha.util.CleanupThread
- All Implemented Interfaces:
- Runnable
public class CleanupThread
- extends Thread
A CleaupThread object represents a thread that helps to for clean up
resources in your application on a regular basis.
The thread does not do the actual cleanup jobs, but holds a
list of cleanable objects and calls the cleanup jobs.
- Author:
- Robert van Loenhout
|
Constructor Summary |
CleanupThread(long interval)
Creates a new cleanup thread. |
|
Method Summary |
void |
add(ICleanable object)
Adds a cleanable object that is periodically called to clean itself. |
protected void |
cleanupAll()
Let the cleanable objects do their jobs. |
void |
run()
Executed when the thread is started. |
| 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 |
CleanupThread
public CleanupThread(long interval)
- Creates a new cleanup thread.
- Parameters:
interval - the interval in seconds between cleanup jobs
add
public void add(ICleanable object)
- Adds a cleanable object that is periodically called to clean itself.
- Parameters:
object - cleanable object
- Throws:
IllegalArgumentException - if an argument is null
cleanupAll
protected void cleanupAll()
- Let the cleanable objects do their jobs.
run
public void run()
- Executed when the thread is started.
- Specified by:
run in interface Runnable- Overrides:
run in class Thread