public class StoppableThread extends java.lang.Object implements Stoppable
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(java.util.function.Function<java.util.function.BooleanSupplier,java.lang.Runnable> 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 |
|---|---|
boolean |
isRunning() |
void |
join() |
void |
join(long millis) |
static StoppableThread |
start(java.util.function.Function<java.util.function.BooleanSupplier,java.lang.Runnable> runnableFactory,
java.util.concurrent.ThreadFactory threadFactory)
Creates, starts and returns a new shutdownable thread.
|
void |
stop()
Stops the service.
|
java.lang.String |
toString() |
protected StoppableThread(java.util.function.Function<java.util.function.BooleanSupplier,java.lang.Runnable> runnableFactory, java.util.concurrent.ThreadFactory threadFactory)
runnableFactory - the factory for the runnable;
the isRunning() condition is passed to the factory as lambdathreadFactory - the factory to provide the threadpublic static StoppableThread start(java.util.function.Function<java.util.function.BooleanSupplier,java.lang.Runnable> runnableFactory, java.util.concurrent.ThreadFactory threadFactory)
runnableFactory - the factory for the runnable;
the isRunning() condition is passed to the factory as lambdathreadFactory - the factory to provide the threadpublic boolean isRunning()
public void stop()
StoppableInvocation has no additional effect if already stopped.
public void join()
public void join(long millis)
public java.lang.String toString()
toString in class java.lang.Object