Search: in
Event dispatching thread
Event dispatching thread Encyclopedia
  Tutorials     Encyclopedia     Dictionary     Directory  
Event_dispatching_thread Email this to a friend      Event_dispatching_thread

Event dispatching thread

The event dispatching thread (EDT) is a background thread used in Java to process events from the Abstract Windowing Toolkit (AWT) graphical user interface event queue. These events are primarily update events that cause user interface components to redraw themselves, or input events from input devices such as the mouse or keyboard. The AWT uses a single-threaded painting model in which all screen updates must be performed from a single thread. The event dispatching thread is the only valid thread to update the visual state of visible user interface components. Updating visible components from other threads is the source of many common bugs in Java programs that use Swing [1].

Contents


Executing code in the EDT

Other application threads can execute code in the event dispatching thread by defining the code in a object and pass it to the helper class or to the . Two methods of these classes allow:

  • synchronous code execution ( or )
  • and asynchronous code execution ( or )

from the EDT.

The method invokeAndWait() should never be called from the event dispatching thread—it will throw an exception. The method or can be called to determine if the current thread is the event dispatching thread.

Another solution for executing code in the EDT is using the worker design pattern. The SwingWorker class, developed by Sun Microsystems, is an implementation of the worker design pattern, and as of Java 6 is part of standard Swing distribution. The open source project Foxtrot provides another synchronous execution solution similar to SwingWorker.

References

  1. This problem is not specific to Java Swing. There is the same issue in most Widget toolkits, as for example Windows Forms, where the BackgroundWorker class performs the same purpose as SwingWorker in Java.

See also

External links





Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article



Related Links in Event dispatching thread

Search for Event dispatching thread in Tutorials
Search for Event dispatching thread in Encyclopedia
Search for Event dispatching thread in Dictionary
Search for Event dispatching thread in Open Directory
Search for Event dispatching thread in Store
Search for Event dispatching thread in PriceGig



Help build the largest human-edited directory on the web.
Submit a Site - Open Directory Project - Become an Editor

Advertisement

Advertisement



Event dispatching thread
Event_dispatching_thread top Event_dispatching_thread

Home - Add TutorGig to Your Site - Disclaimer

©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement