public class StoppableThread extends java.lang.Object implements ThreadLike
runnable in a new thread.
The thread is started immediately upon construction and it can be stopped via stop or auto-close method.| Modifier | Constructor and Description |
|---|---|
protected |
StoppableThread(RunnableFactory runnableFactory,
java.util.concurrent.ThreadFactory threadFactory)
Constructor for stoppable thread; it is recommended to use the static start(..) methods instead.
|
| Modifier and Type | Method and Description |
|---|---|
void |
join(long millis)
Waits at most
millis milliseconds for this Joinable to
die. |
static StoppableThread |
start(RunnableFactory runnableFactory,
java.util.concurrent.ThreadFactory threadFactory)
Creates, starts and returns a new shutdownable thread.
|
void |
stop()
Stops the service.
|
java.lang.Thread.State |
threadState()
Returns the state of the underlying thread.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisRunning, isTerminatedprotected StoppableThread(RunnableFactory runnableFactory, java.util.concurrent.ThreadFactory threadFactory)
runnableFactory - the factory for the runnable;
the keepRunning() condition is passed to the factory as lambdathreadFactory - the factory to provide the threadpublic static StoppableThread start(RunnableFactory runnableFactory, java.util.concurrent.ThreadFactory threadFactory)
runnableFactory - the factory for the runnable;
the keepRunning() condition is passed to the factory as lambdathreadFactory - the factory to provide the threadpublic java.lang.Thread.State threadState()
ThreadStatethreadState in interface ThreadStateThread.getState()public void stop()
StoppableInvocation has no additional effect if already stopped.
public void join(long millis)
Joinablemillis milliseconds for this Joinable to
die. A timeout of 0 means to wait forever.public java.lang.String toString()
toString in class java.lang.Object