• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

locking problem, please review this version

 
Pander Musubi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I've the old Fly By Night assignment and have a problem with my locking and almost have to submit the assignment and time is running out, aaaaagh!
When two different clients try to book some seats on the same flight (record number 2), one doensn't book.
This is part of my code and I can't figure out whats wrong. Clients do not lock, only the very first request is succesfuly booked. Here si the code with some debug lines so you can uderstand the output below.

(In method modify I have the the thread sleep for 5 secs so I can test the locking, when this is over you will see the "modify end sleep")
And this is the result
inside update 2
a inside lock 2
d about to add 2
e leaving lock 2: [2]
about to modify update 2
inside modify
inside update 2
end sleep modify
about to unlock in update 2
UNLOCK about to remove 2 [2]
UNLOCK removed 2 []
a inside lock 2
d about to add 2
e leaving lock 2: [2]
about to modify update 2
inside modify
end sleep modify
about to unlock in update 2
UNLOCK about to remove 2 [2]
UNLOCK removed 2 []
So if for flight with record number 2, a first request is made for 3 seats and inmediately after that a request for same flight for 7 seats, only 3 seats are being booked.
Any help is very welcome. Thanks.
 
Pander Musubi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is also not in my assignment to keep track of who is locking. I think the locking doesn't need to know what client has got/put in what lock, correct?
Other question, a search/refresh/update does to look at any write locks which are there, correct?
 
Pander Musubi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fixed it by changing part of my design
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic