It's not a secret anymore!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes my choice on lock/unlock.help me to decide,Eugene and Andrew Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "my choice on lock/unlock.help me to decide,Eugene and Andrew" Watch "my choice on lock/unlock.help me to decide,Eugene and Andrew" New topic
Author

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

Gerald Kou
Greenhorn

Joined: Jun 03, 2003
Posts: 14
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?
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
I did.
M


Java Regular Expressions
 
wood burning stoves
 
subject: my choice on lock/unlock.help me to decide,Eugene and Andrew