Asynchronous processing in Spring Boot allows long-running tasks to execute in separate threads without blocking the main application flow. This improves responsiveness and throughput, especially for operations such as sending emails, generating reports, or processing notifications.
Consider an e-commerce application where an order is placed.
Place Order
↓
Save Order
↓
Send Email
↓
Generate Invoice
↓
Send Notification
↓
Return Response
User waits until all operations complete.
Place Order
↓
Save Order
↓
Return Response Immediately
↓
Send Email (Background)
Generate Invoice (Background)
Send Notification (Background)
The user receives a faster response while background tasks continue independently.
Step 1: Enable Asynchronous Processing
@EnableAsync
@SpringBootApplication
@EnableAsync
public class Application {
}This enables Spring's asynchronous method execution support.
Step 2: Mark Methods with @Async
@Service
public class EmailService {
@Async
public void sendWelcomeEmail(
String email) {
// Email sending logic
}
}Spring executes this method using a separate thread.
Step 3: Return Results if Required
@Async
public CompletableFuture<String> processReport() {
return CompletableFuture.completedFuture(
"Report Generated");
}This allows the caller to track progress or retrieve results later.
Step 4: Configure Custom Thread Pool
Default thread configuration may not be suitable for production workloads.
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor =
new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(50);
executor.initialize();
return executor;
}@Service
public class EmailService {
public void registerUser() {
sendEmail();
}
@Async
public void sendEmail() {
}
}Customer Transfers Money
↓
Transaction Saved
↓
Response Returned Immediately
↓
SMS Notification Sent Asynchronously
Email Receipt Generated Asynchronously
A concise interview answer is: To enable asynchronous processing in Spring Boot, use @EnableAsync in the configuration class and annotate methods with @Async. Spring executes these methods in separate threads, improving application responsiveness. For production applications, custom ThreadPoolTaskExecutor configurations are recommended, and @Async methods should be invoked from another Spring-managed bean because self-invocation bypasses Spring proxies.
Last updated: 1 November 2026
Previous question: Explain Spring Boot's approach to handling asynchronous operations.