• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to get feedback from lock()

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic