Mercurial > hg > blitz_condensed
view src/org/dancres/blitz/ActiveObjectRegistry.java @ 34:6f68e94c1fb8 default tip
Add CondensedStats monitoring utility, equivalent to vmstat
author | Dominic Cleal <dominic-cleal@cdo2.com> |
---|---|
date | Thu, 05 Aug 2010 11:07:25 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz; import java.util.ArrayList; /** @see org.dancres.blitz.ActiveObject */ public class ActiveObjectRegistry { private static ArrayList theObjects = new ArrayList(); private static boolean haveStarted = false; public synchronized static void add(ActiveObject anObject) { theObjects.add(anObject); // If already started we have to "automagically" start this object. if (haveStarted) anObject.begin(); } public synchronized static void startAll() { haveStarted = true; for (int i = 0; i < theObjects.size(); i++) { ((ActiveObject) theObjects.get(i)).begin(); } } public synchronized static void stopAll() { for (int i = 0; i < theObjects.size(); i++) { ActiveObject myObject = (ActiveObject) theObjects.get(i); myObject.halt(); } } public synchronized static boolean hasStarted() { return haveStarted; } }