|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
org.apache.tapestry.util.JanitorThread
public class JanitorThread
A basic kind of janitor, an object that periodically invokes ICleanable.executeCleanup()
on a set of objects.
The JanitorThread holds a weak reference to the objects it operates on.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static long |
DEFAULT_INTERVAL_MILLIS
Default number of seconds between janitor runs, about 30 seconds. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
JanitorThread()
Creates a new daemon Janitor. |
|
JanitorThread(String name)
Creates new Janitor with the given name. |
|
| Method Summary | |
|---|---|
void |
add(ICleanable cleanable)
Adds a new cleanable object to the list of references. |
long |
getInterval()
|
static JanitorThread |
getSharedJanitorThread()
Returns a shared instance of JanitorThread. |
void |
run()
Alternates between waitForNextPass()and sweep(). |
void |
setInterval(long value)
Updates the property, which may not take effect until the next time the thread finishes sleeping. |
protected void |
sweep()
Runs through the list of targets and invokes ICleanable.executeCleanup()on each of
them. |
String |
toString()
|
protected void |
waitForNextPass()
Waits for the next run, by sleeping for the desired period. |
| 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, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long DEFAULT_INTERVAL_MILLIS
| Constructor Detail |
|---|
public JanitorThread()
public JanitorThread(String name)
| Method Detail |
|---|
public static JanitorThread getSharedJanitorThread()
public long getInterval()
public void setInterval(long value)
value - the interval, in milliseconds, between sweeps.
IllegalStateException - always, if the receiver is the shared JanitorThread
IllegalArgumentException - if value is less than 1public void add(ICleanable cleanable)
protected void sweep()
ICleanable.executeCleanup()on each of
them. WeakReferences that have been invalidated are weeded out.
protected void waitForNextPass()
public void run()
waitForNextPass()and sweep().
run in interface Runnablerun in class Threadpublic String toString()
toString in class Thread
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||