next up previous contents
Next: Methods of the PlatformCommunicationIFace Up: AgentSystem Class Previous: Controlling of (System) Agents   Contents


Shutdown

To shut down the System you have to call the method stopSystem() which does nothing else then setting the running variable to false. When this boolean is false, the loop in the run() will terminate and the terminateSystem() method is being called. The terminateSystem method cleans up the System and terminates the program. This is done in the following order:

  1. Unregistering the System from the MAFFinder.
  2. Calling the terminateAgent() on every Agent residing in the System. This is done by calling the corresponding method on the AgentLoader. The AgentLoader creates a new Thread to conclude the Agent asynchronously. This is important because it can be that after calling this method an Agent still executes. But anyway the agents Hashtable will be cleaned after that.
  3. Calling the terminateAgent() on every System Agent residing in the System. This is done synchronously. After that no System Agent is executing anymore and there should be no more a proxy registered in the System. The sysagents Hashtable is being cleaned.
  4. To give all Agents enough time to terminate themselves in a clean way the System waits the in WAITFORSHUTDOWN given 100ms if there are still other threads running in the thread group of the AgentLoaders where the Agents do have their threads.
  5. When all Agents have stopped their threads in time and so the System is in a clean state to shut down, it calls the System.exit(0) to shut down the JVM (Java Virtual Machine). When not all Agents where terminated it prints out a list of all running threads and exits then with the error code 1.


next up previous contents
Next: Methods of the PlatformCommunicationIFace Up: AgentSystem Class Previous: Controlling of (System) Agents   Contents
Thomas Letsch 2001-02-21