skip to main content
Programmer's documentation > Developing with the JViews Gantt SDK > Using JViews products in Eclipse RCP applications > Threading modes
 
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.
Enable this mode by calling setAWTThreadRedirect or enableAWTThreadRedirect early during initialization.
The following example shows how to enable single-thread mode:
// Switch single-event-thread mode during a static initialization.
      static {
          IlvEventThreadUtil.enableAWTThreadRedirect();
      }
This mode reduces the risk of producing deadlocks. If you are using JComponents other than IlvGanttChart in your application, your JComponents must use the method isDispatchThread rather than http://java.sun.com/javase/7/docs/api/java/awt/EventQueue.html#isDispatchThread() or http://java.sun.com/javase/7/docs/api/javax/swing/SwingUtilities.html#isEventDispatchThread().
* Product Filter[JViews Framework]
At the JViews Framework level, if you are using JComponents other than IlvManager and IlvJManagerViewPanel in your application, your JComponents must use the method isDispatchThread rather than EventQueue.isDispatchThread() (see http://java.sun.com/javase/7/docs/api/java/awt/EventQueue.html#isDispatchThread()) or SwingUtilities.isEventDispatchThread() (see http://java.sun.com/javase/7/docs/api/javax/swing/SwingUtilities.html#isEventDispatchThread().)

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.