• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Booking

 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a question about synchronized like these:
1) I have a class named LockManager whitch do "genCookie", "LockRecord" ,
"unlockRecord" ...
synchronized boolean unlockRecNo(
long recNo , long lockCookie ){
....
}
synchronized boolean lockRecNo(
long recNo , long lockCookie ){
....
}
2) In client, when i Book a seat I do like:
lockManager.LockRecord;
Book;
lockManager.unlock;
Doing like these , is right?
Thank you first.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steven,
Please display a first and a last name. If you put a space between "Steven" and "Gu" we will be happy.
The way you have synchronized your methods implies that you have only one instance of the class that contains those methods. As long as that is true, then this synchronization will work - the synchronization mutex will be the instance of the class.
You need to ensure that there are no other methods that can modify your collection of existing locks - or if there are, that you also have them synchronized on the same instance of the class.
If you have other methods in that class which are synchronized on the instance of the class, then you have a potential bottleneck.
You have both methods returning a boolean, but in your psuedo code demonstrating the use of these methods you have ignored the return value. I suspect that this is just because of your examples - I don't think your real methods return booleans and I doubt that you would ignore the return values.
In your psuedo code you do not have a separate piece of logic to test whether the record is still available for booking. Is that within your call to Book?
Regards, Andrew
 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK
 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will add a blank in steven and Gu
 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much,
i didn't have another logic to test the record is locking now.
i will add it!
 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,I have another question about the customer!
in my dataBase i receive.
<Customer holding this record>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic