• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Safe

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From some articles, it said that if it is required to access Swing components from a thread other than the event dispatching thread, "InvokeLater" should be used for threadsafe.
In my client program, I will create a connection frame when the "Connect" button is clicked. When the window is closed (WindowListener is used), I will try to make connection to the Data Server. Thus, I do not create a new thread in my client program. Does it mean that I do not need to use "InvokeLater"?
I saw that the assignment mentioned the threadsafe requirement. I am not sure if my client program implementation is correct.
Can anyone kindly give me some opinion?
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From my experience I know that displaying a JDialog from the event dispatch thread and performing GUI updates after that could lead to repaint/focus problems, no matter if you use invokeLater or not.
I don't know if it's a bug (that remains in jdk1.4) or it's me.
The only way I've been able to overcome these problems has been by spawning a new thread for each action and use invokeLater to modify the GUI. But I think that is a bit to much for the sort of problems we may face.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mandy, I don't think you will need invokeLater.
However, if you have problems later, you can always try it.
I didn't use it anywhere, and actually don't understand it and where you would use it.
Mark
 
Mandy Yan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
icic. Thanks for your help!
[ July 01, 2002: Message edited by: Mandy Yan ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic