← Questions

Per-key ordered task executor on a thread pool

0
MicrosoftCodingLast asked Sep 2026

Build a component that takes a maximum concurrency and an existing thread-pool executor and exposes submit(key, task). Tasks with the same key must run one at a time in the order they were submitted; tasks with different keys may run in parallel, but never more than the limit at once. Many threads call submit concurrently. Explain your locking, how a key's queue is cleaned up when it drains, what happens when a task throws, and how you would test it.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding