Programming with JViews Maps > Creating a Map Application Using the API > Multithreading > Using the IlvThreadMonitor

IlvThreadedActivityMonitor is a class that monitors the progress of several tasks running in separate threads.

These tasks first register with this monitor through the registerThreadedActivity( ) method, and then notify the monitor of any progress they make by calling the updateActivityProgress( ) method. Eventually, a task can be removed from the list by calling unregisterThreadedActivity( ) method. A task that reports a progress reading of one hundred percent is automatically unregistered from the monitor.

In its turn, the monitor notifies any registered listeners of the progress being made by the monitored tasks. Figure 3.1 shows the IlvThreadedActivityMonitorPanel class, which is a Swing component implementing the IlvThreadedActivityMonitor.ActivityListener interface. It displays progress bars for monitored activities.

multithreadmonitor.png

Figure 3.1 Multithread Monitor

If you want to display the progress of your own threaded tasks on this IlvThreadedActivityMonitorPanel, here are the basic steps you should take:

IlvManagerView view; // the main view of the application
 
// Get the manager of this view (provided that it was set somewhere before)
IlvManager manager = view.getManager();
 
// Get the activity monitor associated with this manager
IlvThreadedActivityMonitor monitor = IlvThreadedActivityMonitorProperty.GetThreadedActivityMonitor(manager);
if (monitor != null) {
	// Notify the monitor of the progress of this activity
monitor.updateActivityProgress(this,100,null);
}; 

For further information about this Bean, see Multithread Monitor.