• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Locking for URLyBird 1.1.1

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DB interface I have has the following signatures for lock and unlock method
public long lock(int recNo) throws RecordNotFoundException;
public void unlock(int recNo, long cookie) throws RecordNotFoundException, SecurityException;
My implementation for lock is something as below

while (reservations.containsKey(recno)) {
lockCookie = (new Date()).getTime() + recno;
reservations.put(recno, lockCookie);

My unlock method reads somehting like
if (reservations.get(recno) == lockCookie) {

Where reservations is a Hashmap and lockReleased is lock.newCondition() where lock is a reentrantlock.

Can you help me find any flaws here? Thanks for all your help.
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done same as you but stuck in testing. Did you find anything after your post which you can share??


BTW: Your assignment is same as mine URLyBird 1.1.1
[ April 27, 2007: Message edited by: Ken Boyd ]
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic