public static void poolClean(long pendingTime) { synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { long sleep = list[i].getSleepTime(); if (sleep != 0 && sleep <= pendingTime) { pool.remove(list[i]); list[i].stopRunning(); } } } }
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(); } } } }
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; }
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; }
public void poolClean(long pendingTime) { synchronized (pool) { ThreadContainer[] list = pool .toArray(new ThreadContainer[pool.size()]); for (int i = 0; i < list.length; i++) { long sleep = list[i].getSleepTime(); if (sleep != 0 && sleep <= pendingTime) { pool.remove(list[i]); list[i].stopRunning(); } } } }
public void interupt() { if (tc == null) return; tc.interrupt(); }
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(); } } } }
public int getPriority() { if (tc != null) return tc.getPriority(); return 0; }
public void setName(String _name) { if (tc != null) tc.setName(_name); }
public ThreadContainer(ThreadGroup group, String pName) { super(group, pName); name = pName; setName(name + " sleeping"); }
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 String getName() { if (tc != null) return tc.getName(); return ""; }
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; }