Solutionunvalidated
Try to to decouple thread creation from task execution. — The CPU maintains a queue and a pool of worker threads (only 3). Tension: Clients submit tasks (like your cpu.execute()). Outcome: Each worker takes a task from the queue, processes it, and picks the next.
cce22ef0-ff9c-48e8-95ee-cd89eeb0f113
Try to to decouple thread creation from task execution. — The CPU maintains a queue and a pool of worker threads (only 3). Tension: Clients submit tasks (like your cpu.execute()). Outcome: Each worker takes a task from the queue, processes it, and picks the next.