File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes my choice on lock/ me to decide,Eugene and Andrew Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "my choice on lock/ me to decide,Eugene and Andrew" Watch "my choice on lock/ me to decide,Eugene and Andrew" New topic

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

Gerald Kou

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.
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)

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

Java Regular Expressions
I agree. Here's the link:
subject: my choice on lock/ me to decide,Eugene and Andrew
It's not a secret anymore!