aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes no need to lock! ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "no need to lock! ??" Watch "no need to lock! ??" New topic
Author

no need to lock! ??

J Hartley
Ranch Hand

Joined: Mar 29, 2001
Posts: 52
Hi, from my FBN instructions....
"Note that the locking required is effectively a "write" lock only. If updates occur to a record that is being displayed on another client, then no change occurs at the other client. However, if two clients attempt to perform the sequence lock, read, modify, write, unlock concurrently, then both modification attempts will be handled correctly. The aim is to ensure that if two customers attempt to book a seat on the same flight concurrently, then the number of available seats is definitely reduced by two, unless there was only one seat, in which case, one customer will be advised at booking time that no more seats are available."
i cant see the need to implement any locking. the modify method is synchronised, so for example
client A sees that there is 1 seat left
client B sees that there is 1 seat left
client A calls modify
client B calls modify
Because client a called first it gets the lock from Data instance. the seats are reduced by 1. client A is happy
Client B then gets the lock and enters the modify method, if there the seats = 0 then report failure, in this particular case it does.
simple eh? am i missing something?
Cheers Joe
 
 
subject: no need to lock! ??
 
Threads others viewed
lock() and unlock() methods
lock and unlock
Locking in modify method?
What exactly constitutes "Booking Time"?
hello ! what is lock() and unlock()?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com