Hi, I have the following problem. My instructions say, that I'm required to implement (among the others) a lock method, which can look like this.
// Locks a record so that it can only be updated or deleted by this client. // bla bla bla... public long lock(int recNo) { }
How is it possible to do it with this argument? I would like to add clientId as a second argument, but this will violate the contract. I implemented my service as a singleton, so I cannot have multiple instances for each client (this would be hard to maintain). How would you conform that requirement without making a spaghetti architecture?
You don't need a clientId. Use synchronized/wait/notify instead. Java helps us to supply multiply threads. I am "very happy" that I don't have to handle additional clientId's; keep it simple