Recall & Review
beginner
What is the purpose of the
@EnableAsync annotation in Spring Boot?The
@EnableAsync annotation tells Spring Boot to enable support for running methods asynchronously, meaning those methods can run in the background without blocking the main thread.Click to reveal answer
beginner
How do you mark a method to run asynchronously after enabling
@EnableAsync?You add the
@Async annotation to the method you want to run asynchronously. This tells Spring to run that method in a separate thread.Click to reveal answer
intermediate
Where should you place the
@EnableAsync annotation in a Spring Boot application?You usually place <code>@EnableAsync</code> on a configuration class or the main application class to enable asynchronous processing across the app.Click to reveal answer
advanced
What happens if you call an <code>@Async</code> method from within the same class without going through Spring's proxy?The
@Async method will not run asynchronously because Spring uses proxies to manage async calls. Calling it internally bypasses the proxy, so it runs synchronously.Click to reveal answer
intermediate
Can you customize the thread pool used by
@EnableAsync? How?Yes, you can customize the thread pool by defining a
TaskExecutor bean and specifying it in the @Async annotation or by overriding the default executor in the configuration.Click to reveal answer
What does the
@EnableAsync annotation do in a Spring Boot app?✗ Incorrect
@EnableAsync activates support for running methods asynchronously in Spring Boot.Which annotation marks a method to run asynchronously after enabling
@EnableAsync?✗ Incorrect
The
@Async annotation marks methods to run asynchronously.Where is the best place to put the
@EnableAsync annotation?✗ Incorrect
@EnableAsync is placed on a configuration or main class to enable async support app-wide.What happens if you call an
@Async method from the same class internally?✗ Incorrect
Internal calls bypass Spring proxies, so
@Async methods run synchronously.How can you customize the thread pool used by
@EnableAsync?✗ Incorrect
You customize the thread pool by defining a
TaskExecutor bean in your configuration.Explain how
@EnableAsync and @Async work together in Spring Boot to run methods asynchronously.Think about how Spring knows which methods to run in the background.
You got /4 concepts.
Describe a common pitfall when calling an
@Async method from within the same class and how to avoid it.Consider how Spring manages async calls behind the scenes.
You got /4 concepts.