In our system, we have a method that will do some work when it\'s called with a certain ID:
public void doWork(long id) { /* ... */ }
Now, this
You could create a list or set of active ids and use wait and notify:
List working;
public void doWork(long id) {
synchronized(working)
{
while(working.contains(id))
{
working.wait();
}
working.add(id)//lock
}
//do something
synchronized(working)
{
working.remove(id);//unlock
working.notifyAll();
}
}
Problems solved:
Problems there: