This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are Default Swing Models Thread-Safe?

 
Josh Britton
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read in the Java Tutorial that "most Swing object methods are not 'thread safe.'" Does that include default Swing Models? In other words, if I am, er, 'in,' a non-EDT thread and I call a method that updates a model, do I need to wrap the call in EventQueue.invokeLater?

Thanks,

josh
 
Brian Cole
Author
Ranch Hand
Posts: 902
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Josh Britton:
I read in the Java Tutorial that "most Swing object methods are not 'thread safe.'" Does that include default Swing Models? In other words, if I am, er, 'in,' a non-EDT thread and I call a method that updates a model, do I need to wrap the call in EventQueue.invokeLater?



Most of the swing models are not thread safe. Were you to update a model on a non-EDT thread, the events would likely be fired on a non-EDT thread too, which can be bad.
 
Josh Britton
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic