- All Implemented Interfaces:
- Executor
public final class SameThreadExecutor
extends Object
implements Executor
A simple executor that runs each task synchronously in the same thread that submits it. Unlike
Guava's MoreExecutors.directExecutor()
and
MoreExecutors.newDirectExecutorService()
, this implementation provides a "trampoline"
that queues the work for the current thread to execute, instead of actually executing it
immediately. This allows for very long chains of tasks without the risk of stack overflow.