Now I only add lock/unlock to those methods which change the record value. But it has a problem: While read the record from db file, does it need to add a reading lock on record? If there hasn't a reading lock. while one client thread is reading the record but another client thread changes the record. so the reading client maybe get two different results(before changed or after changed). I think this is not right. So, do I need to add lock to every method which accesses record (both read and write)?
I do lock->read->modify->unlock when I try to book a flight. But when I show available flights and flights in combobox (which shows the origin and destination of flights) I do an optimist read (Reading without locking), any comment? Jawad
you should not lock for performing a read to display the flights. What flights are displayed to the user are not necessarily garunteed to be available. Locking for updating the display would significantly decrease the performance when there are multiple users.
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad: