This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S locking solution - consumes no CPU cycles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S locking solution - consumes no CPU cycles" Watch "B&S locking solution - consumes no CPU cycles" New topic
Author

B&S locking solution - consumes no CPU cycles

Pepe Luca
Greenhorn

Joined: Feb 06, 2007
Posts: 1
Hi,

I have the B&S project. I implemented the LockManager for this project and I wanted to solve the problem of a thread that must consume no CPU cycles after it tries to lock a resource that has been locked by another client. I thought that it is more important to meet this requirement than the code simplicity (another requirement . I read some other posts with this problem but there was no code posted.

My solution includes 2 HashMaps
1.cookieMap - Used for maintaining the locked records key - recordNumber, value - cookie returned when the record has been locked
2.recordLocks - Used for keeping locks for each record that has been locked.
The LockManager is used as a member in the Data class which is also responsible for detecting if a record for which a client waits to lock was updated/deleted until it acquires the lock.

Please take a look and advise me
Daniel Travin
Greenhorn

Joined: Oct 19, 2007
Posts: 7
Hello Pepe,

it would be much more easier to understand your idea if you provide the code of yoru LockManager as well

Daniel.
 
wood burning stoves
 
subject: B&S locking solution - consumes no CPU cycles
 
Similar Threads
3rd level of locking
Bad locking solution !
B&S logical record locking
My Locking Approach
B&S 2.1.1: lock(), delete() and unlock() confusion