public class SingleThreadContext extends Object implements ThreadContext
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.
|
equals, 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 Scheduled schedule(Duration delay, Runnable runnable)
Schedulerpublic Scheduled schedule(Duration delay, Duration interval, Runnable runnable)
Schedulerpublic void close()
ThreadContextclose in interface ThreadContextclose in interface AutoCloseableCopyright © 2013–2017. All rights reserved.