@EnableAsync switches on Spring's asynchronous method execution. Once it is present on a configuration class, any bean method annotated with @Async is called on a separate thread from a task executor, and the caller returns immediately instead of waiting. Without @EnableAsync, @Async is silently ignored and the method runs synchronously.
Use it for work that does not need to block the request thread, such as sending an email, calling a slow external API or generating a report.
@EnableAsync and @Async work together@EnableAsync and @Async work together@EnableAsync registers a post-processor (AsyncAnnotationBeanPostProcessor) that wraps beans containing @Async methods in a proxy. When code calls such a method through the proxy, the proxy submits the call to a TaskExecutor and returns. The same proxy rules as other Spring annotations apply: only calls from outside the bean go through it.
In Spring Boot, put @EnableAsync on a @Configuration class or on the main application class. Boot auto-configures a default executor, but you still need the annotation to activate @Async processing.
An @Async method must be public and have one of these return types:
| Return type | Use when |
|---|---|
void | Fire and forget; exceptions cannot reach the caller |
Future<T> | You want to block later with get() |
CompletableFuture<T> | You want to compose or chain results (preferred) |
ListenableFuture was deprecated and removed in Spring Framework 7 in favour of CompletableFuture.
The thread name depends on your executor configuration.
Choosing the thread pool matters more than anything else. Without configuration, plain Spring falls back to SimpleAsyncTaskExecutor, which starts a new thread per task and does not reuse them. Spring Boot instead auto-configures a pooled applicationTaskExecutor, with properties under spring.task.execution.*.
Define your own bounded pool and refer to it by name:
Size the queue deliberately: an unbounded queue hides overload until memory runs out.
On Java 21 and later with Spring Boot 3.2 or newer, set spring.threads.virtual.enabled=true and Boot runs the auto-configured async executor on virtual threads. That suits blocking I/O work and removes most pool-sizing decisions.
A CompletableFuture carries the exception to the caller; handle it with exceptionally or handle. For void methods nothing reaches the caller, so register a handler through AsyncConfigurer:
@Async method from another method of the same class. The call bypasses the proxy and runs synchronously.@Async on a private method or on a bean created with new.@Async method run on the same thread?Usually @EnableAsync is missing, or the call is a self-invocation that skips the proxy.
@Async method be transactional?Yes, but the transaction starts on the new thread and is independent of the caller's transaction.
@EnableAsync have?annotation (to detect a custom marker instead of @Async), proxyTargetClass, mode (proxy or AspectJ) and order.
void or CompletableFuture?Return CompletableFuture when you need the result or error. Use void only for true fire-and-forget tasks.
@EnableAsync activates @Async processing through a proxy. Return CompletableFuture for results, configure a bounded executor (or virtual threads on Java 21+), handle void exceptions with an AsyncConfigurer, and avoid self-invocation.