Regardless of which way you do it, you should keep track of which cookies are currently issued for each record.
Hi, Andrew:
I did search on "lock" and have read many of the talks about it. And this is why I am replying to this topic which dated a while back.
Why do I have to keep track of the cookie, could you please explain in more detail? Thanks.
And to be honest, the more I read about the lock/unlock topics, the more I get confused. My implementation of lock is like the following, please let me know if I missed anything:
public long lock(int recn) thorws ...{
if not a valid record throw exception
synchronize lock manager
while recn is locked already, wait
return lock manager.lock record recn
}
unlock
public void unlock(int recN, long cookie) throws ...{
if (not a valid record) throws exception
synchronize lock manager
if lock manager.get lock cookie for recN
throw security exception
lock manager.remove lock on recN
notify whoever is waiting
}
And in the remote interface implementaion, I have the following when updateing a record:
...
long mycookie = data.lock(...)
data.update(...) //or data.create() or data.delete()
data.unlock(..., mycookie)
I don't see a need for keep track of cookie.
I may just have covered the simplest case, please advise. Thanks.
bing