Asynchronous Methods (@Async) — Spring Technical Interview Questions & Answers
Running a method on a separate thread.
Asynchronous Methods (@Async)
- @Async runs a method on another thread so the caller is not blocked.
- Enable with @EnableAsync.
- Useful for sending email/notifications after a request returns.
- Return types can be void or Future/CompletableFuture style results.
- Forgetting to enable async, so the annotation does nothing.
- Async = non-blocking call for background work.
Technical Interview Tip: Enable flag + use case (email after signup).
Code Examples for Asynchronous Methods (@Async)
Asynchronous Methods (@Async) — working example
// Topic: Asynchronous Methods (@Async)
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
class TopicController {
@GetMapping("/api/topic")
String topic() {
return "Spring Boot: Asynchronous Methods (@Async)";
}
}Asynchronous Methods (@Async): GET /api/topic returns this title string.
How to Explain Asynchronous Methods (@Async) to an Interviewer
What is Asynchronous Methods (@Async) (sb misc)?
Used for a short Asynchronous Methods @Async sb misc example a small REST app Not just the heading
Give one small example of Asynchronous Methods (@Async) (sb misc).
the smallest Asynchronous Methods @Async sb misc example you can type Running a method on a separate thread
What mistake do beginners make with Asynchronous Methods (@Async) (sb misc)?
only saying “Asynchronous Methods @Async sb misc” with no example Show the fix
Where do you use Asynchronous Methods (@Async) (sb misc)?
a small REST app a short Asynchronous Methods @Async sb misc example