File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Are Default Swing Models Thread-Safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Are Default Swing Models Thread-Safe?" Watch "Are Default Swing Models Thread-Safe?" New topic
Author

Are Default Swing Models Thread-Safe?

Josh Britton
Greenhorn

Joined: Nov 26, 2008
Posts: 24
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

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Josh Britton
Greenhorn

Joined: Nov 26, 2008
Posts: 24
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are Default Swing Models Thread-Safe?
 
Similar Threads
jsp is by default thead safe or not?
Servlets
Are swing components thread safe?
User threads versus Daemon Threads
Are JSPs thread safe by default or not?