Thread Pool / Parallel Task Executor

Problem Implement a fixed-size thread pool that executes submitted tasks using a bounded set of worker threads, with graceful shutdown.

Requirements

  • submit(task) enqueues work for execution.
  • shutdown() stops accepting new tasks and drains the queue before exiting.
  • A pool of K workers processes a stream of N tasks.

Areas to design

  • The task queue and how idle workers block on it without busy-waiting.
  • Coordinating shutdown so no task is lost and no worker deadlocks.
  • Race conditions on the shared queue and the shutdown flag.

Example

  • Submit N tasks to a pool of K workers; await completion, then shut down cleanly.
added …
LeaderboardSalaryAccount