public final class StoppableThread
extends java.lang.Thread
Constructor and Description |
---|
StoppableThread(java.lang.Runnable r)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
gentleStop(boolean interrupt,
long timeout)
Stop this thread gracefully.
|
void |
start()
Start this thread executing its run method on a separate thread.
|
boolean |
stopping()
this.run should call stopping() at convenient invervals to see if it has been requested to stop.
|
activeCount, checkAccess, clone, 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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
public StoppableThread(java.lang.Runnable r)
r
- class that has a run methodpublic void gentleStop(boolean interrupt, long timeout)
interrupt
- true if this thread should be interrupted from sleep or from doing an I/O (which might close the
channel), before stopping it.timeout
- How long in milliseconds to wait for the thread to die before giving up. 0 means wait forever.
-1 means don't wait at all.public void start()
start
in class java.lang.Thread
java.lang.IllegalThreadStateException
- if this thread is already started.public final boolean stopping()