Interface GUISynchronizer
-
public interface GUISynchronizer
Definition of an interface that supports updating GUI components from different threads.
Typical Java GUI libraries use a specific thread (e.g. event dispatch thread) that is alone responsible for updating GUI components. When working with multiple threads special care has to be taken if GUI components are to be accessed; it has to be ensured that such operations are only performed on the event dispatch thread.
This interface provides a generic way for such updates. It defines typical operations that deal with an event dispatch thread: to invoke a code block synchronously or asynchronously on this thread. Concrete, platform specific implementations have to use the appropriate means provided by the platform they encapsulate to ensure that this code gets executed on the event dispatch thread.
- Version:
- $Id: GUISynchronizer.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
asyncInvoke(Runnable runnable)
Invokes the given runnable object asynchronously on the event dispatch thread.boolean
isEventDispatchThread()
Returns a flag whether the current thread is the event dispatch thread.void
syncInvoke(Runnable runnable)
Invokes the given runnable object synchronously on the event dispatch thread.
-
-
-
Method Detail
-
asyncInvoke
void asyncInvoke(Runnable runnable)
Invokes the given runnable object asynchronously on the event dispatch thread. This method will no block, the code of the runnable will be executed some time in the future.- Parameters:
runnable
- the code to be executed on the event dispatch thread
-
syncInvoke
void syncInvoke(Runnable runnable) throws GUIRuntimeException
Invokes the given runnable object synchronously on the event dispatch thread. The calling thread will block until the runnable's execution is finished.- Parameters:
runnable
- the code to be executed on the event dispatch thread- Throws:
GUIRuntimeException
- if an error occurs
-
isEventDispatchThread
boolean isEventDispatchThread()
Returns a flag whether the current thread is the event dispatch thread.- Returns:
- a flag if the current thread is the event dispatch thread
-
-