Close

Spring - Task Execution Introduction

[Last Updated: Feb 11, 2026]

Spring Core framework provides abstraction of task execution. Task execution is referred as creating a new thread and perform some task in it. Spring's task execution abstraction hides implementation differences between Java SE 1.4, Java SE 5 and Java EE environments. Spring underlying implementation can be based on Java Executor framework or a simple Java thread or even it can be based on a third party library like Quartz.



The interfaces


java.util.concurrent.Executor Executor org.springframework.core.task.TaskExecutor TaskExecutor org.springframework.core.task.AsyncTaskExecutor AsyncTaskExecutor org.springframework.core.task.AsyncListenableTaskExecutor AsyncListenableTaskExecutor LogicBig

Spring task execution is based on the TaskExecutor and it's sub-interfaces.

The diagram on the left is interactive and clickable, it will take you the api pages.

  • TaskExecutor is same as Executor interface.
  • AsyncTaskExecutor can handle Callable submission and returns Future.
  • AsyncListenableTaskExecutor returns ListenableFuture on task submission, which can attach listener to get callbacks on task completion. Deprecated since Spring 6.0 and added methods in AsyncTaskExecutor which return CompletableFuture. This class has been removed in Spring 7.0.

Definition of TaskExecutor

Version: 7.0.3
 package org.springframework.core.task;
 @FunctionalInterface
 public interface TaskExecutor extends Executor {
     void execute(Runnable task); 
 }

Definition of AsyncTaskExecutor

Version: 7.0.3
 package org.springframework.core.task;
 public interface AsyncTaskExecutor extends TaskExecutor {
     default void execute(Runnable task, 1
                          long startTimeout);
     default Future<?> submit(Runnable task); 2
     default <T> Future<T> submit(Callable<T> task); 3
     default CompletableFuture<Void> submitCompletable(Runnable task); 4
     default <T> CompletableFuture<T> submitCompletable(Callable<T> task);
         5
 }
1Execute the given task.
2Submit a Runnable task for execution, receiving a Future representing that task. (Since 3.0)
3Submit a Callable task for execution, receiving a Future representing that task. (Since 3.0)
4Submit a Runnable task for execution, receiving a CompletableFuture representing that task. (Since 6.0)
5Submit a Callable task for execution, receiving a CompletableFuture representing that task. (Since 6.0)

Definition of AsyncListenableTaskExecutor

Version: 6.2.15
 package org.springframework.core.task;
 @Deprecated(since = "6.0", forRemoval = true)
 @SuppressWarnings("removal")
 public interface AsyncListenableTaskExecutor extends AsyncTaskExecutor {
     org.springframework.util.concurrent.ListenableFuture<?>
         submitListenable(Runnable task); 1
     <T> org.springframework.util.concurrent.ListenableFuture<T>
         submitListenable(Callable<T> task); 2
 }
1Submit a Runnable task for execution, receiving a ListenableFuture representing that task.
2Submit a Callable task for execution, receiving a ListenableFuture representing that task.

AsyncListenableTaskExecutor has been deprecated in 6.0, in favor of AsyncTaskExecutor.submitCompletable(Runnable) and AsyncTaskExecutor.submitCompletable(Callable)

AsyncListenableTaskExecutor has been removed in Spring 7.0.

Definition of ListenableFuture

Version: 6.2.15
 package org.springframework.util.concurrent;
 @Deprecated(since = "6.0", forRemoval = true)
 public interface ListenableFuture<T> extends Future<T> {
     void addCallback(ListenableFutureCallback<? super T> callback); 1
     void addCallback(SuccessCallback<? super T> successCallback, 2
                      FailureCallback failureCallback);
     default CompletableFuture<T> completable(); 3
 }
1Register the given ListenableFutureCallback.
2Java 8 lambda-friendly alternative with success and failure callbacks. (Since 4.1)
3Expose this ListenableFuture as a JDK CompletableFuture. (Since 5.0)

This class has been removed in Spring 7.0.

Definition of SuccessCallback

Version: 6.2.15
 package org.springframework.util.concurrent;
 @Deprecated(since = "6.0", forRemoval = true)
 @FunctionalInterface
 public interface SuccessCallback<T> {
     void onSuccess(@Nullable T result); 1
 }
1Called when the ListenableFuture completes with success.

SuccessCallback has been removed in Sping 7.0.

Definition of FailureCallback

Version: 6.2.15
 package org.springframework.util.concurrent;
 @Deprecated(since = "6.0", forRemoval = true)
 @FunctionalInterface
 public interface FailureCallback {
     void onFailure(Throwable ex); 1
 }
1Called when the ListenableFuture completes with failure.

FailureCallback has been removed in Spring 7.0.


In this tutorial we have introduced commonly used task executors. There are more. Please checkout reference document TaskExecutor types list. In the next tutorial we will give examples for Spring TaskExecutor implementation.

See Also

Join