0
0
Spring Bootframework~5 mins

Custom thread pool configuration in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ATaskScheduler
BThreadPoolExecutorService
CThreadPoolTaskExecutor
DExecutorServiceFactory
What does setting 'maxPoolSize' in a thread pool do?
ALimits the maximum number of threads that can run concurrently
BSets the number of tasks in the queue
CDefines the minimum number of threads
DSpecifies the timeout for threads
If the task queue is full and the thread pool has reached maxPoolSize, what happens to new tasks?
AThey are rejected or handled by a rejection policy
BThey wait indefinitely
CThey create new threads beyond maxPoolSize
DThey are automatically canceled
Which annotation can you use to enable asynchronous method execution with a custom thread pool in Spring Boot?
A@AsyncConfig
B@EnableAsync
C@ThreadPool
D@AsyncExecutor
What is a good reason to customize the thread pool size in a Spring Boot app?
ATo disable concurrency
BTo make the app slower
CTo avoid using threads
DTo match the workload and hardware capabilities for better performance
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.