for (int i=0; i<instArrayCount; i++) {
final int j = i;
Runnable work = new Runnable() {
public void run() {
try {
MInstance anInst = (MInstance) instArray.objectAtIndex(j);
if ( (anInst.isScheduled()) && (anInst.nearNextScheduledShutdown(rightNow)) ) {
if (anInst.isGracefullyScheduled()) {
localMonitor.stopInstance(anInst);
} else {
localMonitor.terminateInstance(anInst);
}
anInst.calculateNextScheduledShutdown();
}
} catch (MonitorException me) {
NSLog.err.appendln("Exception while scheduling: " + me.getMessage());
}
}