}
ThreadContainer start(MThread _task, String _name) {
ThreadContainer tc = null;
synchronized (pool) {
if (housekeeper == null) {
housekeeper = new ThreadHousekeeper();
MSingleton.instance().getHousekeeper().register(housekeeper, SLEEP_TIME, true);
}
// 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",tc.getId());
tc.setName(_name);
tc.newWork(_task);
}
return tc;
}