Threading modes
You can handle the SWT-Swing user interface events in one or two threads.
NOTE Single-thread mode is incompatible with AWT/Swing Dialogs. If you use single-thread mode, you cannot use AWT
Dialogs, Swing
JDialogs, or modal
JInternalFrames in your application. There are also some other limitations. See the class
IlvEventThreadUtil for a precise description of the limitations.
Two-thread mode
The SWT events are handled in the SWT event thread and AWT/Swing events are handled in the AWT/Swing event thread. This is the default mode.
You can switch between the two threads by using the SWT method Display.asyncExec() and the AWT method EventQueue.invokeLater().
If your application uses this mode, you must be careful to:
Make API calls on SWT widgets only in the SWT event thread. Otherwise, you will get
SWTExceptions of type
ERROR_THREAD_INVALID_ACCESS.
Make API calls on JComponents, which include, only in the AWT/Swing event thread. Otherwise, you risk deadlocks.
Single-thread mode
In single-thread mode, SWT and AWT/Swing events are handled in the same thread.
Single-thread mode reduces the risk of producing deadlocks.
The following example shows how to enable single-thread mode:
// Switch single-event-thread mode during a static initialization.
static {
IlvEventThreadUtil.enableAWTThreadRedirect();
}
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.