🎓 BookMCQ
← Back to 4. Threads in Operating System

📝 Thread Pools in operating system (33 MCQs)

Preallocated Worker Threads and Task Execution

A thread pool is a group of reusable worker threads maintained to execute submitted tasks. It belongs to application and runtime concurrency management and reduces the need to create a new thread for every incoming request. Workers wait for available tasks, execute assigned work, and return to an available state. The pool controls concurrency through a configured or dynamically adjusted number of worker threads.

Why Repeated Thread Creation Creates Overhead

Applications such as web servers may receive thousands of short requests. Creating and terminating a new thread for each request consumes memory and processor time. Unrestricted thread creation can also overwhelm system resources. A thread pool addresses these problems by reusing existing workers and limiting the number of simultaneously executing tasks.

Task Queues, Worker Allocation, and Completion

When a task arrives, the application submits it to a pool-managed queue. An available worker removes the task, executes it, and reports or stores the result. After completion, the worker returns to the available pool. If every worker is busy, additional tasks wait in the queue until capacity becomes available.

Serving Requests with a Five-Thread Pool

Consider a web server using five worker threads and receiving eight requests simultaneously. Five workers begin processing requests, while the remaining three wait in the task queue. When one worker completes its request, it retrieves the next waiting task. This arrangement limits active worker execution while supporting reuse of existing threads.

Throughput, Queueing Delays, and Pool Capacity

Thread pools reduce creation overhead and prevent unbounded thread growth, improving resource control in servers and background-processing systems. However, a pool that is too small creates queueing delays, while an excessively large pool increases memory use and context switching. Blocking tasks can occupy workers for long periods, reducing the capacity available for new work.

Misconceptions About Reusable Worker Threads

'A thread pool creates a new thread for every request' is incorrect because its primary purpose is worker reuse. 'A fixed pool guarantees that every task starts immediately' is incorrect because tasks may wait in a queue. 'Increasing pool size always increases throughput' is incorrect because CPU, memory, and I/O resources impose limits.

Exam Focus: Worker Counts and Task Queue Behaviour

Trace task submission, queueing, worker allocation, completion, and worker reuse. Given five workers and eight simultaneous tasks, identify how many begin immediately and how many initially wait. Questions may examine pool sizing, queue limits, blocked workers, resource exhaustion, and the relationship between thread pools and implicit threading.

Key Terms of Thread Pools

  • Thread pool - Reusable collection of worker threads.
  • Worker - Thread executing an assigned task.
  • Task queue - Stores pending work.
  • Pool size - Number of available worker threads.
  • Queueing delay - Time spent awaiting execution.
  • Worker reuse - Executing multiple tasks with one thread.
11
Easy
11
Medium
11
Hard

📝 All Thread Pools in operating system MCQs

Q1. A web server creates a new operating-system thread for every request. During traffic spikes, thread creation and destruction consume significant resources. Which redesign most directly addresses this problem?

A.Create additional threads for every request
B.Reuse a bounded collection of worker threads to execute submitted tasks ✅
C.Create a separate process for every request
D.Handle every request sequentially with no background work
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A thread pool reuses existing workers across multiple tasks, avoiding repeated creation and destruction. A bounded pool also limits concurrent thread resources, helping the server handle bursts without allowing thread count to grow without control.

Q2. What does a conventional worker thread do after completing a task obtained from a pool queue?

A.It terminates immediately
B.It creates a new process for the next task
C.It returns to waiting for another available task ✅
D.It permanently reserves the same task identifier
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A worker usually remains alive after completing its assigned task. It returns to the pool, waits for more work, and retrieves another queued task when available, amortizing thread creation costs across multiple submissions.

Q3. A pool has eight workers and receives 100 runnable tasks. All workers are busy. What normally happens to the other tasks in a conventional queued pool?

A.They wait in the work queue until workers become available ✅
B.They execute simultaneously on the eight occupied workers
C.They are converted automatically into separate processes
D.They are discarded as soon as the queue receives them
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A conventional pool queues tasks when all workers are occupied. As each worker finishes its current task, it retrieves another task from the queue, so submitted work can exceed the number of available worker threads.

Q4. A pool uses a FIFO task queue and three workers. Task A is removed first but takes 20 ms, while tasks B and C each take 2 ms. Which statement is generally correct?

A.FIFO guarantees A, B, and C finish in that order
B.B and C cannot start until A finishes
C.The queue automatically gives A a higher processor priority
D.Tasks may start or finish in an order different from submission order ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: FIFO generally determines task removal order, not completion order across concurrent workers. B and C may finish before A because their execution durations are shorter, even when A was removed from the queue first.

Q5. Two servers perform the same tasks. One creates a new thread for every task; the other reuses a fixed pool. Their task execution times are similar. Why may the pooled server still have lower total response time?

A.It eliminates every scheduling and synchronization cost
B.It avoids repeated thread-creation and termination overhead ✅
C.It guarantees that no task waits in a queue
D.It forces every task to execute on a separate core
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Similar task execution times do not imply equal total response times. Reusing workers avoids repeated setup and teardown costs, although queue waiting, scheduling, synchronization, and the task's actual execution time still matter.

Q6. A service configures a fixed pool with a maximum of 12 workers. Under heavy load, 40 tasks are submitted. Which statement about the worker count is correct?

A.The pool must create 40 workers
B.The pool must reduce its worker count to one
C.The pool cannot exceed 12 workers under this fixed configuration ✅
D.The pool automatically converts excess tasks into processes
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A fixed pool with a maximum of twelve workers limits its worker population to that configured capacity. Excess submitted tasks must wait, be rejected, or follow another defined policy rather than increasing the worker count beyond the limit.

Q7. A pool has a maximum of eight workers and a queue capacity of twenty tasks. Eight tasks are running and twenty are queued. Five additional tasks arrive, and the configured policy rejects submissions when the queue is full. What should happen?

A.The five tasks should be rejected or handled by the configured overflow policy ✅
B.The five tasks should replace the currently running tasks
C.The pool should create five unrestricted workers
D.The queue should automatically expand without limit
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: All eight workers are occupied and all twenty queue positions are full. Under the stated rejection policy, the five new submissions cannot be accepted and must be rejected or handled through an explicitly configured alternative.

Q8. A service uses a bounded pool and a bounded task queue. During a traffic burst, requests arrive faster than workers can complete them. What is the principal system-level benefit of the limits?

A.They guarantee every request completes immediately
B.They eliminate the need to monitor request failures
C.They make task execution time constant
D.They prevent uncontrolled worker and queue growth, allowing overload to be handled explicitly ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Bounded workers and queues constrain resource consumption when arrivals exceed service capacity. Requests may wait or be rejected, but explicit overload handling is safer than allowing threads and queued work to grow without limit.

Q9. A workload consists of independent CPU-bound tasks that do not block. The server has eight effective CPU cores. Which initial worker-pool size is a reasonable baseline for experiments?

A.One worker for every task, regardless of workload size
B.Approximately eight workers, followed by measurement and tuning ✅
C.A thousand workers to keep all cores busy
D.One worker, because CPU-bound tasks cannot execute concurrently
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: For CPU-bound tasks that remain runnable, a starting pool size near the number of effective cores avoids excessive oversubscription. Measurement is still necessary because scheduling, memory behavior, and other system activity influence the best size.

Q10. A service receives 500 tasks per second. Each task occupies a worker for an average of 0.02 seconds. Ignoring bursts and overhead, approximately how many workers are needed to match the average offered workload?

A.5
B.8
C.10 ✅
D.25
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Average worker demand is arrival rate multiplied by worker occupancy: 500×0.02=10500 \times 0.02 = 10 worker-seconds per second. Ten workers approximately match the average offered workload, although bursts and variability may require additional capacity.

Q11. A pool is used for many tasks that spend most of their time waiting for network or storage responses. Why might a pool larger than the number of CPU cores be useful?

A.Every waiting task executes instructions continuously
B.A larger pool guarantees that no task ever blocks
C.A larger pool increases the physical core count
D.Some workers may be blocked, so additional workers can perform useful work while others wait ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: I/O-bound tasks can occupy workers while waiting for external events. A larger pool may keep processors productive by allowing other tasks to run, but excessive workers consume memory and can increase contention, so measurement remains essential.

Q12. A four-worker pool runs a mix of short database queries and long file conversions. When conversions begin, query latency rises sharply. Which change most directly addresses the likely cause?

A.Separate blocking conversions from short queries using appropriately sized pools ✅
B.Force every query to wait until all conversions finish
C.Reduce the queue capacity to zero
D.Make every conversion execute twice
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Long or blocking conversions can occupy all workers, leaving short queries queued. Separate pools isolate the workloads and allow independent capacity choices, reducing interference without requiring unlimited threads or uncontrolled resource consumption.

Q13. A dynamically growing pool responds quickly during bursts but uses substantially more memory than a fixed pool. What is the best way to choose between them?

A.Choose the dynamic pool because response time is the only relevant measure
B.Choose the fixed pool because fewer workers always improve throughput
C.Compare latency, throughput, memory use, scheduling overhead, and the expected workload ✅
D.Ignore memory use because worker threads do not require resources
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Dynamic growth can improve responsiveness when fixed capacity is insufficient, but it consumes additional resources and may increase contention. A sound choice measures latency, throughput, memory, and scheduling costs against the service's workload and objectives.

Q14. A pool has six workers. Six tasks each wait synchronously for a network response lasting eight seconds. Another short task arrives one second later. Assuming all workers remain occupied, when can the short task begin?

A.Immediately, because network waits do not occupy workers
B.After a worker completes or otherwise becomes available, potentially around eight seconds after the first tasks started ✅
C.Exactly 48 seconds after arrival
D.It can never execute once a pool becomes full
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Each blocking task continues occupying its worker while waiting for the network response. Since all six workers are unavailable, the short task must wait until a worker becomes free, unless the implementation supplies additional execution capacity.

Q15. A fixed pool contains four workers. Each running task waits synchronously for a fifth task queued in the same pool, and the fifth task is needed for all four tasks to finish. What is the principal risk?

A.The fifth task must preempt one blocked worker automatically
B.The pool will increase its worker count without a limit
C.The queue will execute the fifth task inside every waiting task
D.The pool may stop making progress because all workers are waiting for queued work ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: All four workers are occupied by tasks waiting for a dependent task that cannot start. The pool has no free worker to execute that dependency, creating thread-starvation deadlock; nonblocking composition or separate capacity can avoid it.

Q16. A team observes that a shared task queue is protected by one mutex. Increasing workers from four to sixty-four raises lock contention but barely improves throughput. What is the most likely bottleneck?

A.A single shared queue has become a synchronization bottleneck ✅
B.The operating system has stopped supporting concurrent execution
C.The tasks no longer need to be queued
D.The mutex guarantees unlimited parallel access
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A single shared queue can serialize task acquisition when many workers compete for its mutex. More workers then increase contention without proportional useful work, so profiling and scalable queue designs may be appropriate.

Q17. A pool's workers retrieve tasks from a shared queue. A programmer assumes that the thread-safe queue makes every task's shared data safe automatically. What is the flaw?

A.A queue can only store immutable tasks
B.Workers in one process cannot access common memory
C.Queue safety protects queue operations, not arbitrary shared mutable state accessed by tasks ✅
D.Submitting a task makes every variable atomic
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A thread-safe queue protects its own internal operations and task transfer. Tasks can still access shared variables concurrently, so their data needs appropriate synchronization, atomic operations, or immutability to avoid races.

Q18. A pool has tasks A, B, and C in a FIFO queue. Two workers become available almost simultaneously. Which ordering guarantee is safest to assume without additional coordination?

A.A must finish before B starts
B.The tasks may start or finish in an order different from submission order ✅
C.C must finish before B
D.All tasks must start and finish in strict FIFO order
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A FIFO queue may provide submission-order removal, but multiple workers execute tasks concurrently. Different task durations and scheduling can change start or completion order, so strict completion ordering requires additional coordination.

Q19. A worker task fails because of invalid input. The pool framework's exception behavior is not documented. What should a robust application do?

A.Assume every task succeeds because a worker executed it
B.Ignore the error because the worker remains reusable
C.Terminate the whole server for every task failure
D.Define failure reporting and recovery, and verify how the framework propagates or records task errors ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Executing a task does not guarantee successful completion. Pool frameworks may capture, propagate, log, or expose failures through task results, so applications should define recovery behavior and verify the specific implementation's error semantics.

Q20. A service must shut down while a pool contains queued and running tasks. Which policy best supports graceful termination?

A.Stop accepting new tasks, then allow accepted tasks to finish under a defined shutdown policy ✅
B.Delete the queue before notifying workers
C.Terminate every worker immediately without checking task state
D.Continue accepting tasks until the shutdown wait expires
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Graceful shutdown normally rejects new submissions and gives accepted tasks an opportunity to complete, subject to a defined timeout or cancellation policy. This avoids unnecessary loss of work and reduces the risk of leaving resources inconsistent.

Q21. A pool has four workers. Task A submits task B to the same pool and waits synchronously for B's result. All four workers behave similarly. What can happen?

A.All dependent tasks execute simultaneously on new workers
B.The pool automatically converts each task into a process
C.The workers may all block while their dependent tasks remain queued ✅
D.The queue guarantees that dependent tasks run before their submitters wait
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When every worker blocks waiting for dependent tasks queued in the same fixed pool, no worker remains to execute those tasks. This can cause thread-starvation deadlock; nonblocking task composition avoids occupying workers while waiting.

Q22. A web service uses a bounded pool. During overload, submissions are rejected, but callers receive no notification. Which operational improvement is most important?

A.Retry every rejected request continuously without delay
B.Provide explicit rejection handling, metrics, and a suitable retry or backpressure strategy ✅
C.Remove the worker limit immediately
D.Discard all rejection records because they were not executed
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A bounded pool protects resources by rejecting work when capacity is exhausted. Without reporting, callers cannot respond appropriately; explicit errors, metrics, and controlled retries or backpressure help the service manage overload safely.

Q23. A worker finishes task T1 and immediately obtains T2 from the queue. Which advantage does this reuse provide?

A.T2 inherits the complete private stack contents of T1
B.The worker no longer requires scheduling
C.T2 is guaranteed to execute on the same processor core forever
D.The pool avoids paying thread-creation and teardown costs for every task ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: The worker remains available after T1 completes and can execute T2 without creating another thread. Reuse amortizes lifecycle costs across tasks, although each task still requires execution time and any necessary synchronization.

Q24. A database allows at most five concurrent connections, but an application pool has eight workers. All eight workers request a connection at once and wait synchronously if none is available. What is a likely consequence?

A.Some workers may wait for connections, reducing effective concurrency and increasing queueing ✅
B.The database automatically increases its limit to eight
C.All eight tasks must execute database operations simultaneously
D.The pool ignores the connection limit without any effect
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The database permits only five concurrent connections, so at least three requests cannot acquire one immediately. Those workers may remain occupied while waiting, reducing useful pool capacity and increasing latency for other tasks.

Q25. A pool has a maximum of eight workers and a queue capacity of twenty tasks. Eight tasks are running and fifteen are queued. Three new tasks arrive simultaneously. Under a reject-on-full policy, how many can be accepted into the queue?

A.Zero
B.One
C.Three ✅
D.Five
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The queue has capacity for twenty tasks and currently contains fifteen, leaving five available positions. All three new tasks fit, so the pool can accept three without exceeding its configured queue limit.

Q26. A service receives tasks in bursts. Its fixed pool has four workers, while its queue can hold only two pending tasks. If four tasks are running and six more arrive before any worker finishes, how many can be queued?

A.Six
B.Two ✅
C.Four
D.Zero
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: All four workers are occupied, and the queue capacity is two. Therefore, only two of the six arriving tasks can enter the queue; the remaining four must follow the configured rejection or overflow policy.

Q27. A graph gives worker count and completed tasks per second: (1,20), (2,37), (3,49), (4,55), and (5,55). What trend is best supported?

A.Throughput decreases whenever a worker is added
B.Throughput rises by the same amount with every additional worker
C.The fifth worker doubles throughput
D.Throughput increases initially and then reaches a plateau ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Throughput rises from 20 to 55 tasks per second, then remains at 55 when the fifth worker is added. This suggests a bottleneck or saturation point where additional workers provide no measured gain.

Q28. A graph records worker count and average queue wait: (2,40 ms), (4,24 ms), (6,15 ms), (8,14 ms), and (10,14 ms). What conclusion follows?

A.Queue wait decreases initially but shows little further improvement after eight workers ✅
B.Queue wait increases linearly with the worker count
C.Eight workers produce the highest possible throughput on every workload
D.The data prove that tasks never block
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Average queue wait falls from 40 to 14 milliseconds as the pool grows to eight workers, then remains unchanged. The measurements suggest additional workers beyond eight do not improve this workload's queue delay.

Q29. A pool is tuned for CPU-bound work on a four-core machine. The team increases workers from four to twenty, but throughput remains nearly unchanged while context switches rise. What is the best interpretation?

A.Twenty workers must be required for CPU-bound tasks
B.The processor has automatically become a twenty-core system
C.The additional runnable workers may add scheduling overhead without increasing useful CPU capacity ✅
D.The pool has stopped accepting submitted work
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Four cores already provide four simultaneous ordinary CPU execution paths. Increasing runnable workers to twenty may add context switching and contention without adding hardware capacity, explaining why throughput remains nearly unchanged.

Q30. A team separates short queries from long conversions into two pools. Which result would most strongly support this change?

A.Both pools show higher memory use and worse latency for every request
B.Short-query latency improves during conversion bursts without unacceptable resource growth ✅
C.Long conversions stop requiring processor time
D.All requests complete in submission order automatically
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Separate pools can prevent long blocking conversions from occupying every worker needed by short queries. Improved query latency during bursts, while keeping memory and scheduling overhead acceptable, is evidence that workload isolation is useful.

Q31. A worker pool has three workers. Each worker runs a task that waits for another task queued in that same pool. The queue contains all three required follow-up tasks. What is the likely result?

A.The follow-up tasks execute on the blocked workers automatically
B.The pool doubles its worker count by default
C.The waiting tasks finish because queue order guarantees dependency completion
D.No worker is available to execute the queued follow-up tasks, so the pool can deadlock ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: All three workers are blocked waiting for follow-up tasks that remain queued. Since no worker is free to execute those tasks, the dependency cannot be satisfied and the pool can stop making progress.

Q32. A pool handles independent requests, but tasks have highly variable durations. Some workers become idle while another worker has a long backlog. Which mechanism can improve load distribution?

A.Work stealing, allowing idle workers to obtain tasks from other workers' queues ✅
B.A rule that reserves all queued tasks for the first worker
C.A global lock preventing idle workers from accessing queues
D.A requirement that every worker execute only one task during its lifetime
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Work stealing lets an idle worker obtain available tasks from another worker's queue, improving load balance when task durations vary. Its benefit depends on queue design, dependencies, and the synchronization cost of stealing work.

Q33. A server receives 600 tasks per second, and each task occupies a worker for 0.01 seconds on average. Ignoring bursts and overhead, approximately how many workers are needed to match the average offered workload?

A.3
B.12
C.6 ✅
D.60
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Average worker demand is arrival rate multiplied by average occupancy: 600×0.01=6600 \times 0.01 = 6 worker-seconds per second. Six workers approximately match the average offered workload, but bursts and service-time variability may require headroom.

🔗 Related Topics (MCQs)