Event dispatching thread: Difference between revisions

Content deleted Content added
Stolsvik (talk | contribs)
Swing and thread safety: Added a reference to tutorial from Oracle (former Sun) which states that UI components must be created and accessed on EDT.
Line 4:
 
Most [[Abstract Window Toolkit|AWT]] and [[Swing (Java)|Swing]] object methods are not [[Thread safety|thread safe]]: invoking them from multiple threads risks thread interference or memory consistency errors.<ref>{{cite web
| url=http://javadownload.sunoracle.com/docs/booksjavase/tutorial/uiswing/concurrency/dispatch.html
| title=The Event Dispatch Thread
| publisher=[[Sun Microsystems]]
| accessdate=2011-10-02}}</ref>
| accessdate=2010-03-19}}</ref><ref>http://weblogs.java.net/blog/alexfromsun/archive/2005/11/debugging_swing_1.html</ref> To avoid these problems, Swing standards state{{fact|date=July 2010}} that all [[Graphical user interface|user interface]] components should be created '''and''' accessed '''only''' from the AWT event dispatch thread. A popular third-party [[Pluggable look and feel|Look and Feel]] named [http://substance.dev.java.net/ Substance] goes as far as to refuse to instantiate any Swing component off of the Event Dispatch Thread,<ref>http://www.pushing-pixels.org/?p=368</ref> to prevent coders from making such a mistake.
<ref>{{cite web
| url=http://weblogs.java.net/blog/alexfromsun/archive/2005/11/debugging_swing_1.html
| title=Debugging Swing - is it really difficult?
| publisher=[http://www.java.net/blogs/alexfromsun/ Alexander Potochkin]
| accessdate=2011-10-02}}
</ref>
To avoid these problems, Swing standards state that all [[Graphical user interface|user interface]] components should be created '''and''' accessed '''only''' from the AWT event dispatch thread<ref>{{cite web
| url=http://download.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
| title=Initial Threads
| publisher=[[Sun Microsystems]]
| accessdate=2011-10-02}}</ref>.
| accessdate=2010-03-19}}</ref><ref>http://weblogs.java.net/blog/alexfromsun/archive/2005/11/debugging_swing_1.html</ref> To avoid these problems, Swing standards state{{fact|date=July 2010}} that all [[Graphical user interface|user interface]] components should be created '''and''' accessed '''only''' from the AWT event dispatch thread. A popular third-party [[Pluggable look and feel|Look and Feel]] named [http://substance.dev.java.net/ Substance] goes as far as to refuse to instantiate any Swing component off of the Event Dispatch Thread,<ref>http://www.pushing-pixels.org/?p=368</ref> to prevent coders from making such a mistake.
 
== Executing code in the EDT ==