• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it True that Swing isn't thread Safe ?  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it true that Swing isn't Thread safe ?
how can we develop an application that thread safe and can get the Java Gui advantage ?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it true that Swing isn't Thread safe ?
Yes. With rare exceptions, you should only access the Swing classes from the GUI event dispatcher thread.
how can we develop an application that thread safe and can get the Java Gui advantage ?
By, when you need to execute Swing code from other threads, using javax.swing.SwingUtilities.invokeLater(Runnable) and ...invokeAndWait(Runnable). They execute the Runnable you pass in, in the GUI thread.
Sun has a very good article on the topic as part of the Swing tutorial.
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!