public class SameThreadSubmitterExecutor extends java.lang.Object implements SubmitterExecutor
SubmitterExecutor
that will run all provided tasks immediately in the same thread
that is invoking into it with the task. This is different from calling the runnable directly
only in that no exceptions will propagate out. In the case of just execute(Runnable)
thrown exceptions will be provided to ExceptionUtils.handleException(Throwable)
to be
handled. Otherwise thrown exceptions will be represented within their returned
ListenableFuture
.Constructor and Description |
---|
SameThreadSubmitterExecutor()
Deprecated.
Use
instance() |
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.Runnable task) |
static SameThreadSubmitterExecutor |
instance()
Call to get a default instance of the
SameThreadSubmitterExecutor . |
<T> ListenableFuture<T> |
submit(java.util.concurrent.Callable<T> task)
Submit a
Callable to run as soon as possible. |
<T> ListenableFuture<T> |
submit(java.lang.Runnable task,
T result)
Submit a task to run as soon as possible.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
submit
@Deprecated public SameThreadSubmitterExecutor()
instance()
public static SameThreadSubmitterExecutor instance()
SameThreadSubmitterExecutor
. Because there is
no saved or shared state, the same instance can be reused as much as desired.public void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
SubmitterExecutor
Future.get()
method will
return the provided result once the runnable has completed.submit
in interface SubmitterExecutor
T
- type of result for futuretask
- runnable to be executedresult
- result to be returned from resulting future .get() when runnable completespublic <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
SubmitterExecutor
Callable
to run as soon as possible. This is needed when a result needs to
be consumed from the callable.submit
in interface SubmitterExecutor
T
- type of result returned from the futuretask
- callable to be executed