public static int poolWorkingSize() { int size = 0; synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { if (list[i].isWorking()) size++; } } return size; }
public int poolWorkingSize() { int size = 0; synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { if (list[i].isWorking()) size++; } } return size; }
public static void poolClean() { synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { if (!list[i].isWorking()) { pool.remove(list[i]); list[i].stopRunning(); } } } }
private static ThreadContainer start(MThreadPoolDaemon _task, String _name) { // search free thread ThreadContainer tc = null; synchronized (pool) { for (int i = 0; i < pool.size(); i++) if (!pool.elementAt(i).isWorking()) { tc = pool.elementAt(i); break; } if (tc == null) { tc = new ThreadContainer(group, "AT_" + pool.size()); tc.setDaemon(true); tc.start(); pool.addElement(tc); } log.t("###: NEW THREAD",tc.getId()); tc.setName(_name); tc.newWork(_task); } return tc; }
ThreadContainer start(MThreadPool _task, String _name) { ThreadContainer tc = null; synchronized (pool) { if (housekeeper == null) { housekeeper = new ThreadHousekeeper(); MApi.lookup(MHousekeeper.class).register(housekeeper, CFG_SLEEP_TIME.value()); } // search free thread for (int i = 0; i < pool.size(); i++) if (!pool.elementAt(i).isWorking()) { tc = pool.elementAt(i); break; } if (tc == null) { tc = new ThreadContainer(group, "AT" + pool.size()); tc.start(); pool.addElement(tc); } log().t("###: NEW THREAD@POOL",tc.getId()); tc.setName(_name); tc.newWork(_task); } return tc; }
public void poolClean() { synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { if (!list[i].isWorking()) { pool.remove(list[i]); list[i].stopRunning(); } } } }