Package org.springframework.core.task
Class SyncTaskExecutor
- java.lang.Object
- org.springframework.core.task.SyncTaskExecutor
- All Implemented Interfaces:
Serializable
,Executor
,TaskExecutor
public class SyncTaskExecutor extends Object implements TaskExecutor, Serializable
TaskExecutor
implementation that executes each task synchronously in the calling thread.Mainly intended for testing scenarios.
Execution in the calling thread does have the advantage of participating in it's thread context, for example the thread context class loader or the thread's current transaction association. That said, in many cases, asynchronous execution will be preferable: choose an asynchronous
TaskExecutor
instead for such scenarios.- Since:
- 2.0
- Author:
- Juergen Hoeller
- See Also:
SimpleAsyncTaskExecutor
, Serialized Form
Constructor Summary
Constructors Constructor Description SyncTaskExecutor()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(Runnable task)
Executes the giventask
synchronously, through direct invocation of it'srun()
method.
Constructor Detail
SyncTaskExecutor
public SyncTaskExecutor()
Method Detail
execute
public void execute(Runnable task)
Executes the giventask
synchronously, through direct invocation of it'srun()
method.- Specified by:
execute
in interfaceExecutor
- Specified by:
execute
in interfaceTaskExecutor
- Parameters:
task
- theRunnable
to execute (nevernull
)- Throws:
IllegalArgumentException
- if the giventask
isnull