• 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

my choice on lock/unlock.help me to decide,Eugene and Andrew

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After reading most posts about lock() and LockManager,I want to implement the lock mechanism with simplest way.I want only use a HashSet to stroe the locked record number,don't use a HashMap to store record number and clientid. The reason is:
1.I can implements the lock()/unlcok as the signature of requirement need:lock(int record) not LockManager.(int record,Object clientId).
2.As the important key:using HashSet can also fulfill the requirement "The unlock method simply
removes the lock from the specified record. If an attempt is made to unlock a record that has not
been locked by this connection, then no action is be taken" .
when method bookFlight excutes,the sequence is lock, read, modify, write, unlock .So when several clients requent the same record,Only one client can get the record's lock and only the
same client can unlock the record.Meanwhile 0ther client can't get the record's lock and perform
the unlock method.
My means is: the case as below can't occur.
A.lock(21);
...
B.lock(21);
...
A.lock(21);
My choise on lock have little extendable capability.But I think it is exacltly satisfied with the requirement of FBN(Although LockManager is also a good choise).
please point out Whether I will lost mark when using the simple design.Did someone use the
similar design and pass the exam?
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did.
M
reply
    Bookmark Topic Watch Topic
  • New Topic