A problem that I try to understand and solve states the following:
There is a set of tasks, each with some index targetId, and this set has to be executed concurrently in an efficient way. The Executor cannot execute tasks with the same targetId concurrently, but it can do so for many tasks with different targetId. A limit on the number of concurrent threads is also given (maxThreads; if 0, it's assumed there's no limit).
The program that attempts to do so is (https://codeshare.io/PdRZ1o). However, sometimes it fails to pass some tests. The issue is the program must execute tasks with the same targetId in the exact order they appear in the queue (which can be filled up during the execution). How to modify the code?
There is a set of tasks, each with some index targetId, and this set has to be executed concurrently in an efficient way. The Executor cannot execute tasks with the same targetId concurrently, but it can do so for many tasks with different targetId. A limit on the number of concurrent threads is also given (maxThreads; if 0, it's assumed there's no limit).
The program that attempts to do so is (https://codeshare.io/PdRZ1o). However, sometimes it fails to pass some tests. The issue is the program must execute tasks with the same targetId in the exact order they appear in the queue (which can be filled up during the execution). How to modify the code?