I have many clients Ai (A1,...,An) everyone of which does the action X. And a server B which does the action Y. But Y could only be done only if there is no one executes X.
So I think of the mutex lock: every client has an own lock Li. It's no problem for clients, but it will be horrible for the server B, something like this:
synchronized(L1){
synchronized(L2){
...
}
}
Is there any better solution for this kind of problem?