Recall & Review
beginner
What is a thread pool in Spring Boot?
A thread pool is a group of pre-created threads that can be reused to execute tasks concurrently. It helps manage system resources efficiently by limiting the number of active threads.
Click to reveal answer
beginner
How do you define a custom thread pool in Spring Boot?
You create a @Bean method that returns a ThreadPoolTaskExecutor, configuring properties like core pool size, max pool size, and queue capacity.
Click to reveal answer
beginner
What does the 'corePoolSize' property control in a thread pool?
It controls the number of threads that are always kept alive in the pool, even if they are idle.
Click to reveal answer
beginner
Why is it important to configure a thread pool instead of creating new threads for each task?
Creating new threads for each task is costly and can exhaust system resources. A thread pool reuses threads, improving performance and resource management.
Click to reveal answer
intermediate
What is the role of 'queueCapacity' in a Spring Boot thread pool?
It defines how many tasks can wait in the queue before new threads are created or tasks are rejected.
Click to reveal answer
Which Spring Boot class is commonly used to create a custom thread pool?
✗ Incorrect
ThreadPoolTaskExecutor is the standard Spring Boot class to configure thread pools.
What does setting 'maxPoolSize' in a thread pool do?
✗ Incorrect
maxPoolSize limits how many threads can run at the same time in the pool.
If the task queue is full and the thread pool has reached maxPoolSize, what happens to new tasks?
✗ Incorrect
New tasks are rejected or handled by a configured rejection policy when the queue and threads are full.
Which annotation can you use to enable asynchronous method execution with a custom thread pool in Spring Boot?
✗ Incorrect
@EnableAsync enables asynchronous processing and allows specifying a custom thread pool.
What is a good reason to customize the thread pool size in a Spring Boot app?
✗ Incorrect
Customizing thread pool size helps optimize resource use and app responsiveness.
Explain how to create and configure a custom thread pool in Spring Boot.
Think about the steps to set up a reusable group of threads for tasks.
You got /4 concepts.
Describe why using a thread pool is better than creating new threads for each task in a Spring Boot application.
Consider system resources and task execution speed.
You got /4 concepts.