skip to main content
Charts > Programmer's documentation > Developing with the JViews Charts 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 IlvChart and IlvLegend, only in the AWT/Swing event thread. Otherwise, you risk deadlocks.
You can switch between the two threads by using the SWT method Display.asyncExec() and the AWT method EventQueue.invokeLater().
*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 IlvChart and IlvLegend in your application, your JComponents must use the method isDispatchThread rather than EventQueue.isDispatchThread() or SwingUtilities.isEventDispatchThread().
NOTE This 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.

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