Swiftorial Logo
Home
Swift Lessons
Tutorials
Learn More
Career
Resources

Spring Boot FAQ: Top Questions

35. How does Spring Boot support async processing with @Async?

Spring Boot supports asynchronous processing using @Async annotation, which allows methods to run in separate threads.

πŸ—ΊοΈ Setup:

  1. Enable async support using @EnableAsync.
  2. Annotate methods with @Async.

πŸ“₯ Example:

@Async
public void asyncMethod() {
  Thread.sleep(5000);
  System.out.println("Completed async task");
}

πŸ† Expected Output:

Method runs asynchronously without blocking caller thread.

πŸ› οΈ Use Cases:

  • Sending emails or notifications in the background.
  • Parallel execution of independent processes.