This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Please comment on lock method implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Please comment on lock method implementation" Watch "Please comment on lock method implementation" New topic
Author

Please comment on lock method implementation

Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
Hi Guys,
After reading lots of thread and comment about lock method I end up with this implementation

1- Check if record numner is -1 then turn on a databaselocking flag and call lockDatabase method
2- If record number is positive then check if databaselocking flag is on then ignore request(I am not sure about this , please comment) and if databaselocking is off call lockRecord method
3- All lockDatabase do is to check if another client has databaseLockOwner object or clients has any lock of any records(looping through all records in hashmap and check for the owner(clientID)), if it's true then wait else assign the clientID to databaseLockOwner
4- lockRecord is a simple method to assign recordlock to client
I tried to make it as simple as I could , your comments will be really appreciated
Thanks
Sam
 
GeeCON Prague 2014
 
subject: Please comment on lock method implementation