Per-key ordered task executor on a thread pool
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.
No answer yet. Write the first one; the best answer gets endorsed.
