Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get feedback from lock()

 
Shailendra Guggali
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friend
I have a probelem which you might have already solved
When a Client is waiting in the lock method as that record is already locked by someone else, how do you convey this back to the Client.
lock( int recNum, String ClientID)
{
if(record not locked)
{
put this record in Hashtable
i.e., lock this record
}
else
{
wait();
till the unlock method is called by the earlier client which will call the notifyAll()
/// AT THIS STAGE HOW DO YOU INFORM THIS CLIENT
(GUI ) THAT THE RECORD IS LOCKED AND HE HAS TO WAIT.
}
}
I am using RMI
Thanx for sparing your valuable time
Shailendra
 
Andras Nemeth
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailendra Guggali:
wait();
till the unlock method is called by the earlier client which will call the notifyAll()
/// AT THIS STAGE HOW DO YOU INFORM THIS CLIENT
(GUI ) THAT THE RECORD IS LOCKED AND HE HAS TO WAIT.
Thanx for sparing your valuable time
Shailendra

Do you implement an active client? With RMI callback?
If not, I would invokeLater at the GUI and from that call the lock while I would write to the Status line (or window) that
"Booking (if you e.g the lock in the booking)is in progress. Please, be patient! "
The wording is really important at an UI.
Ban
 
Shailendra Guggali
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read about SwingWorker but couldn't figure out how to use.
My bookTicket() goes something like this ::
Double click on the JTable row
MouseListener picks up - transfers to Controller which calls
bookTicket() method
bookTicket() method -
calls lock()
{
if record locked - wait()
// from here I want to tell the client that his // thread is waiting - and prevent him from using the JTable
when notifyAll() called -- moves out of wait
// again inform client that his request is now being processed
}
calls readRecord()
checks avail seats
calls modify()
calls unlock()
{
checks ClientID and removes record from HT
notifiesAll()
}
Now how do you perform invokeLater()
"If not, I would invokeLater at the GUI and from that call the lock while I would write to the Status line (or window)"
My main concern is that if the Client who is blocked, keeps doubleClicking on the JTablerow( thinking nothing is happening) it could create another problem - machine hangs. Is there a way we can disable listeners to the JTable till the lock is removed??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic