Package org.jgroups.util
Class Runner
- java.lang.Object
-
- org.jgroups.util.Runner
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Runnable
public class Runner extends java.lang.Object implements java.lang.Runnable, java.io.CloseableRuns a given function in a loop (in a separate thread) until it is stopped- Since:
- 4.0
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandaemonprotected ThreadFactoryfactoryprotected java.lang.Runnablefunctionprotected longjoin_timeoutprotected booleanrunningprotected java.lang.Runnablestop_functionprotected java.lang.Threadthreadprotected java.lang.Stringthread_name
-
Constructor Summary
Constructors Constructor Description Runner(ThreadFactory factory, java.lang.String thread_name, java.lang.Runnable function, java.lang.Runnable stop_function)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleandaemon()Runnerdaemon(boolean d)longgetJoinTimeout()java.lang.ThreadgetThread()booleanisRunning()voidrun()RunnersetJoinTimeout(long t)Runnerstart()Runnerstop()java.lang.StringthreadName()RunnerthreadName(java.lang.String n)
-
-
-
Field Detail
-
factory
protected final ThreadFactory factory
-
thread_name
protected java.lang.String thread_name
-
function
protected final java.lang.Runnable function
-
stop_function
protected final java.lang.Runnable stop_function
-
running
protected volatile boolean running
-
thread
protected java.lang.Thread thread
-
daemon
protected boolean daemon
-
join_timeout
protected long join_timeout
-
-
Constructor Detail
-
Runner
public Runner(ThreadFactory factory, java.lang.String thread_name, java.lang.Runnable function, java.lang.Runnable stop_function)
-
-
Method Detail
-
getThread
public java.lang.Thread getThread()
-
isRunning
public boolean isRunning()
-
daemon
public boolean daemon()
-
daemon
public Runner daemon(boolean d)
-
threadName
public java.lang.String threadName()
-
threadName
public Runner threadName(java.lang.String n)
-
getJoinTimeout
public long getJoinTimeout()
-
setJoinTimeout
public Runner setJoinTimeout(long t)
-
start
public Runner start()
-
stop
public Runner stop()
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
-