An
com.google.common.util.concurrent.ListeningExecutorService implementation that also allows
for an
Executor to be specified on construction that is used to execute
ListenableFuture callback
Runnables, registered via
com.google.common.util.concurrent.Futures#addCallback or
ListenableFuture#addListener directly, asynchronously when a task that is run on this executor completes.
This is useful when you want to guarantee listener callback executions are off-loaded onto another thread to avoid
blocking the thread that completed the task, as a common use case is to pass an executor that runs tasks in the same
thread as the caller (i.e.
MoreExecutors#sameThreadExecutor) to
ListenableFuture#addListener.
Most commonly, this class would be used in lieu of
MoreExecutors#listeningDecorator when the underlying
delegate Executor is single-threaded, in which case, you may not want ListenableFuture callbacks to block the single
thread.
Note: the Executor specified on construction does not replace the Executor specified
in
ListenableFuture#addListener. The latter Executor is still used however, if it is detected that
the listener Runnable would execute in the thread that completed the task, the listener is executed on Executor
specified on construction.