• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI Client screen refresh problem when waiting for the Flight Record to be unlocked ?

 
Arvind Popli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do anyone of you guys have encountered this problem:
CASE: When the Client A trys to lock a record (on the remote server) and that particular record is locked by some other Client B, the first Client A request thread is put on wait/hold.
PROBLEM: Now the problem is that- the Client A's screen is unable to refresh. Only when the lock on that particular record is released by Client B and all the waiting threads are notified, then the Client A's screen is able refresh and display's the correct messages etc...
QUESTION: How can the Client A's screen be still be refreshed even when it is waiting for the lock to be released ?
The locking/unlocking works perfectly on non-GUI clients.
Thanks,
Arvind
 
veron luis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind,
My advise to you is to make your project simple..I passed this exam without having that kind of "refresh" functionality..
Regards,
Luis
 
Matthew Comer
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You are doing all of your db work on the Swing event dispatching thread. This leads to the problem that you have noticed. There are ways around this, but all are more complicated. In a real-world app you would likely NOT be able to get away with this behavior, but for the assignment it should be ok.
If you are interested in fixing the problem anyway, you will need to create a Runnable object (or subclass Thread, though this is less academically correct) and have this new object do the work on a new thread. Your GUI can either monitor the progress of this work via some kind of flags that you implement on the runnable object (though remember to synchronize access to these flags!) or the runnable can do something on the GUI with SwingUtilities.invokeLater() or SwingUtilities.invokeAndWait(). Be careful NOT to update the GUI from a non-Swing thread, as Swing is NOT threadsafe.
A good Swing book will cover this material...
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's excellent tutorial material about Swing and threads on Sun's Java site. You'll probably pass without using worker threads, but you're likely to score higher if you do use them. As mentioned above you won't be able to do without them in the real world.
- Peter
 
Arvind Popli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter, Matthew and Luis for the information. I shall definitely look into it.
-Arvind
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic