public class TemporaryCloseableThread
extends java.lang.Thread
TemporaryCloseable
objects and
close them to save resources.Constructor and Description |
---|
TemporaryCloseableThread(long period)
Creates a new thread that checks
TemporaryCloseable objects. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(TemporaryCloseable temporaryCloseable)
Add a
TemporaryCloseable object to the waiting list. |
boolean |
remove(TemporaryCloseable temporaryCloseable)
Removes the given
TemporaryCloseable object from the waiting list. |
void |
run() |
void |
setPeriod(long period)
Change the checking period.
|
activeCount, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, checkAccess, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public TemporaryCloseableThread(long period)
TemporaryCloseable
objects.
Do not forget to callperiod
- the checking period in millisecondspublic boolean add(TemporaryCloseable temporaryCloseable)
TemporaryCloseable
object to the waiting list.temporaryCloseable
- the object to add to the waiting listpublic boolean remove(TemporaryCloseable temporaryCloseable)
TemporaryCloseable
object from the waiting list.temporaryCloseable
- the object to remove from the waiting listpublic final void setPeriod(long period)
period
- the new checking period in millisecondspublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread