public static void stop(PageContext pc, Log log) { stop(pc, new StopException(pc.getThread()), log); }
@Override public void run() { // scheduleThread.start(); boolean firstRun = true; List<ControlerThread> threads = new ArrayList<ControlerThread>(); CFMLFactoryImpl factories[] = null; while (state.active()) { // sleep SystemUtil.sleep(interval); factories = toFactories(factories, contextes); // start the thread that calls control ControlerThread ct = new ControlerThread(this, factories, firstRun, configServer.getLog("application")); ct.start(); threads.add(ct); if (threads.size() > 10 && lastMinuteInterval + 60000 < System.currentTimeMillis()) configServer .getLog("application") .info("controller", threads.size() + " active controller threads"); // now we check all threads we have Iterator<ControlerThread> it = threads.iterator(); long time; while (it.hasNext()) { ct = it.next(); // print.e(ct.hashCode()); time = System.currentTimeMillis() - ct.start; // done if (ct.done >= 0) { if (time > 10000) configServer .getLog("application") .info("controller", "controler took " + ct.done + "ms to execute sucessfully."); it.remove(); } // failed else if (ct.t != null) { LogUtil.log(configServer.getLog("application"), Log.LEVEL_ERROR, "controler", ct.t); it.remove(); } // stop it! else if (time > TIMEOUT) { SystemUtil.stop(ct); // print.e(ct.getStackTrace()); if (!ct.isAlive()) { configServer .getLog("application") .error( "controller", "controler thread [" + ct.hashCode() + "] forced to stop after " + time + "ms"); it.remove(); } else { LogUtil.log( configServer.getLog("application"), Log.LEVEL_ERROR, "controler", "was not able to stop controller thread running for " + time + "ms", ct.getStackTrace()); } } } if (factories.length > 0) firstRun = false; } }