The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Was the lock successful? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Was the lock successful?" Watch "Was the lock successful?" New topic

Was the lock successful?

poornima sudharshan

Joined: May 18, 2001
Posts: 18
I have a screen which displays the JTable showing all the flight records selected by the user.Now when the user selects a flight,I lock the record, & take him to the reservation screen where the user selects the number of seats to be booked.
My question is I do not want to take the user to the reservation screen until the I lock the record successfully.( which means that the record is in my HashMap ).
At present in lock method, if the record is already present in the HashMap,the thread simply goes to the wait state.
My only concern is I do not want to show him the number of seats to be booked until I am sure that his record is being locked.
Please reply,
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
In my opinion it is a bad idea to hold a lock while the user is deciding if they want to book a flight. What if they go to lunch and forget?
I think that a lock should be held for as short a time as possible. If it were not for the Sun requirements, it would be even better to provide a BookFlight() method in the server interface so the client never does the lock.
I agree. Here's the link:
subject: Was the lock successful?
It's not a secret anymore!