Bird
0
0

You want to combine a custom thread pool with Spring Boot's scheduling support to run scheduled tasks asynchronously. Which two steps are necessary to achieve this?

hard📝 Application Q9 of 15
Spring Boot - Async Processing
You want to combine a custom thread pool with Spring Boot's scheduling support to run scheduled tasks asynchronously. Which two steps are necessary to achieve this?
ADefine a ThreadPoolTaskScheduler bean and annotate the configuration class with @EnableScheduling
BDefine a ThreadPoolTaskExecutor bean and annotate the configuration class with @EnableAsync
CDefine a ThreadPoolTaskScheduler bean and annotate the configuration class with @EnableAsync
DDefine a ThreadPoolTaskExecutor bean and annotate the configuration class with @EnableScheduling
Step-by-Step Solution
Solution:
  1. Step 1: Identify scheduler bean for scheduled tasks

    Scheduled tasks use ThreadPoolTaskScheduler, not ThreadPoolTaskExecutor.
  2. Step 2: Enable scheduling support

    @EnableScheduling activates scheduled task processing in Spring Boot.
  3. Final Answer:

    Define a ThreadPoolTaskScheduler bean and annotate with @EnableScheduling -> Option A
  4. Quick Check:

    Scheduling = ThreadPoolTaskScheduler + @EnableScheduling [OK]
Quick Trick: Use ThreadPoolTaskScheduler with @EnableScheduling for scheduled tasks [OK]
Common Mistakes:
  • Using ThreadPoolTaskExecutor for scheduled tasks
  • Confusing @EnableAsync with @EnableScheduling
  • Omitting scheduler bean definition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes