public class SingleThreadContext extends AbstractThreadContext
This is a basic ThreadContext implementation that uses a
ScheduledExecutorService to schedule events on the context thread.
| Constructor and Description |
|---|
SingleThreadContext(String nameFormat)
Creates a new single thread context.
|
SingleThreadContext(ThreadFactory factory)
Creates a new single thread context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the context.
|
void |
execute(Runnable command) |
Scheduled |
schedule(Duration delay,
Duration interval,
Runnable runnable)
Schedules a runnable at a fixed rate.
|
Scheduled |
schedule(Duration delay,
Runnable runnable)
Schedules a runnable after a delay.
|
block, isBlocked, unblockequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckThread, currentContext, currentContextOrThrow, isCurrentContextpublic SingleThreadContext(String nameFormat)
The provided context name will be passed to AtomixThreadFactory and used
when instantiating the context thread.
nameFormat - The context nameFormat which will be formatted with a thread number.public SingleThreadContext(ThreadFactory factory)
factory - The thread factory.public void execute(Runnable command)
public Scheduled schedule(Duration delay, Runnable runnable)
Schedulerdelay - the delay after which to run the callbackrunnable - the callback to runpublic Scheduled schedule(Duration delay, Duration interval, Runnable runnable)
Schedulerdelay - the initial delayinterval - the interval at which to run the callbackrunnable - the callback to runpublic void close()
ThreadContextCopyright © 2013–2019. All rights reserved.