• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

B&S locking solution - consumes no CPU cycles

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Pepe,

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

Daniel.
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic