Reputation: 1309
Using Java I need to implement the following architecture: There are multiple queues with jobs continuously coming in the queues. There is a single thread picking up jobs from the queues following a scheduling algorithm. I should be able to write my own scheduling algorithm. Can you please tell me which Java API to use to implement this? I have used ThreadPoolExecutor, but with this I could implement a single job queue and a thread pool containing multiple threads. Thanks in advance!
Upvotes: 0
Views: 1006
Reputation: 24857
Use multiple concurrent queues and one semaphore. In the producers, push objects and signal the semaphore. In the one consumer, wait on the 'common' semaphore and then poll the queues according to your scheduling algorithm - one of them must have an object on it.
Upvotes: 3