|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--com.primix.tapestry.util.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.
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(java.lang.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, then interrupts the thread. |
protected void |
sweep()
Runs through the list of targets and invokes ICleanable.executeCleanup()
on each of them. |
java.lang.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, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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(java.lang.String name)
Method Detail |
public static JanitorThread getSharedJanitorThread()
public long getInterval()
public void setInterval(long value)
the
- interval, in milliseconds, between sweeps.java.lang.IllegalStateException
- always, if the receiver is the shared JanitorThreadjava.lang.IllegalArgumentException
- if value is less than 1public void add(ICleanable cleanable)
protected void sweep()
ICleanable.executeCleanup()
on each of them. WeakReference
s that have been invalidated
are weeded out.protected void waitForNextPass()
public void run()
waitForNextPass()
and
sweep()
.run
in class java.lang.Thread
public java.lang.String toString()
toString
in class java.lang.Thread
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |