Dave,
In your MonitorThread, create a synchronized workerCompleted() method that takes the WorkerThread that is done with its task. The method should add the WT to MT's List of completed WTs. It then wakes up the MT using notify() or interrupt() or some other signal so that it can process the newly completed WT.
You should check out Doug Lea's Concurrent library for some very handy threading classes.
I'm still not getting how to implement long running Monitors efficiently.
I have implemented this much so far:
1> workers complete their task and add themselves into a hashtable by invoking Monitor's workerCompleted() method (this is synchronized) ofcourse;
after this notifies itself;
2> Now monitor knows its a worker has completed its task; So does some work() goes back to waiting state.
Is this the most efficient implementation..
Viz, Doug Leas util.concurrent package; Channel looks most promising... I need to do read more on how its applicable to currnet scenario..
I would appreciate future suggestions
Ravi