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.Closeable
Runs 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 boolean
daemon
protected ThreadFactory
factory
protected java.lang.Runnable
function
protected long
join_timeout
protected boolean
running
protected java.lang.Runnable
stop_function
protected java.lang.Thread
thread
protected java.lang.String
thread_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 void
close()
boolean
daemon()
Runner
daemon(boolean d)
long
getJoinTimeout()
java.lang.Thread
getThread()
boolean
isRunning()
void
run()
Runner
setJoinTimeout(long t)
Runner
start()
Runner
stop()
java.lang.String
threadName()
Runner
threadName(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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-