ThreadManagementFramework is a tool for the control of threads created by an application. It can ensure that, during the entire the life cycle of the application, never more than X threads will run simultaneously. The organization for managing threads inside the framework can be represented by a graph of areas, as described below.
Users can configure a set of areas to their needs via an XML file. For example, the XML declaration for the graph above is :
<!DOCTYPE area PUBLIC "-//objectweb.org//DTD ObjectWeb Area Management 1.0//EN" "ow_area.dtd"> <area name="OTM" description="ObjectWeb Thread Management" limit="200"> <alarm class="org.objectweb.area.lib.DefaultAlarm"/> <!-- Alarm2 --> <area name="java" description="Java packages" limit="100"> <alarm class="org.objectweb.area.lib.OutOfMemoryAlarm"/> <!-- Alarm1 --> <java package="java."/> <java package="javax."/> <java package="sun."/> </area> <area name="OW packages" description="ObjectWeb packages" limit="100"> <java package="org.objectweb."/> </area> <area name="local" description="Local packages" limit="100"> <java package=""/> </area> </area>
Areas have been defined for managing a group of resources, in this case threads. Thus, we can separate the management of every Area and associate a specific behaviour to each one of them. The XML configuration file represents a graph, and an area is a node of this graph, thus, each one has a parent (save the root area), can have a limit and trig an alarm (also present in the graph too) when the limit is reached.
Each area is dedicated to accept threads, according to a specific criteria, like the package in which the threads are created. When a thread enters an area, it enters in the parent area also. Thus, the root area (declared at the begining of the file) counts all the threads created by the application.
To ensure this property, the Thread class is modified via ASM for entering an Area before start, and exiting the Area after exit.