skip to main content
Programmer's documentation > Building Web Applications > Developing JViews Charts JavaScript Web applications > Choosing the multithreading mode
 
Choosing the multithreading mode
Charts components can be used in two modes, regarding multithreading. They differ in their choice of which thread to use for executing the paint() operations.
The using event thread mode is suitable for Swing GUI applications. It causes all drawing and all Swing API accesses to be performed in the AWT EventQueue thread. This is a Swing requirement.
The current thread mode causes the drawing to be performed in the caller thread, regardless whether it is the AWT EventQueue thread or not.
The current thread mode has some advantages for server-side processing, namely:
*It increases performance, especially on multiprocessor machines, to process every request in its originating thread. (The AWT-Event thread can be executed on only one processor at any time.)
*Better interoperability with Tomcat. (Some versions of Tomcat 5 do not terminate properly upon request from the "shutdown" script when the AWT-Event thread has been in use.)
The drawback of the current thread mode is that it is unable to draw other JComponents than IlvChart, IlvChart.Area, IlvLegend and IlvLegendItems, except for header and footer: these can be drawn if they are JLabel instances.
To set the mode for all charts, use the static method IlvChart.setNoEventThreadUpdate.
If set to true, this method activates the current thread mode; if set to false, it activates the using event thread mode.
To set the mode for an individual chart, use the method IlvChart.setUsingEventThread.
If set to true, it activates the using event thread mode; if set to false, it activates the current thread mode.
The default in general is the using event thread mode. The default for JSF components is the current thread mode. The default for an individual chart is according to the general setting ( getNoEventThreadUpdate() ).
There are methods in the IlvChart class that can have two different behaviors, according to the mode: using event thread or current thread mode. These methods are:
 
using event thread mode
current thread mode
paint
paintCurrentThread
print
printCurrentThread
paintToFO
paintToFOCurrentThread
toImage
toImage
toPNG
toPNG
Other functionality, however, takes automatically into account the isUsingEventThread() result.
In any case, the IlvChartServletSupport base class handles all these threading issues for you. It ensures that all the requests to modify a chart and to generate its image are moved from the HTTP request thread onto the AWT event dispatch thread, as necessary. If you need to extend the basic functionalities and plug your own mechanism, you must consider this multithreading issue, and look at the services provided by the IlvServletUtil class.

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