The @Async annotation in Spring lets a method execute on a separate thread rather than the caller's thread, enabling non-blocking, fire-and-forget or background processing within an otherwise synchronous application.
A user registration flow calls an @Async-annotated method to send a welcome email, so the HTTP response returns to the client immediately while the email is sent on a background thread.
@Configuration
@EnableAsync
class AsyncConfig {
@Bean(name = "emailExecutor")
ThreadPoolTaskExecutor emailExecutor() {
ThreadPoolTaskExecutor ex = new ThreadPoolTaskExecutor();
ex.setCorePoolSize(4);
ex.setMaxPoolSize(8);
ex.setQueueCapacity(500);
ex.setThreadNamePrefix("email-");
return ex;
}
}
@Service
class EmailService {
@Async("emailExecutor")
public CompletableFuture<Void> sendWelcome(String email) {
mailSender.send(buildWelcome(email)); // runs on an "email-" thread
return CompletableFuture.completedFuture(null);
}
}
@Service
class RegistrationService {
void register(User user) {
userRepository.save(user);
emailService.sendWelcome(user.email()); // returns immediately
// Note: calling an @Async method from the SAME class bypasses the proxy
// and runs synchronously.
}
}A concise interview answer is
@Async offloads a method to a background thread so the caller doesn't block waiting for it, which I use for things like sending notifications or processing large datasets. It requires @EnableAsync, and I return a CompletableFuture when the caller actually needs to know the outcome.
Last updated: 1 November 2026
Previous question: In Spring, what is the difference between @Mock and @MockBean annotations?
Next question: How does Spring handle scheduling and task execution?