File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are Default Swing Models Thread-Safe?

 
Josh Britton
Greenhorn
Posts: 24
  • 0
  • 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: 886
1
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic