public static void configure(ServletContext context, String packages, ThreadPoolConfig... configs) throws Exception { _servletContext = context; _threadPoolContainer = MyThreadPoolExecutorContainer.addThreadPools(configs); _threadPoolContainer.setEventDispatcher( new EventDispatcher<Event>() { @Override public boolean dispatchEvent(Event event, boolean isRightNow) throws Exception { if (isRightNow) { IEventHandler<Event> handler = getEventHandler(event.getType()); if (handler != null) { long beginNano = System.nanoTime(); handler.doExecute(event); long useTime = System.nanoTime() - beginNano; } else { _doNothingHandler.doExecute(event); } } else { _threadPoolContainer.execute(MyThread.currentThread().getThreadPoolName(), event); } return true; } }); _servletContext.setAttribute( ServletContextKeyEnum.THREADPOOL_EXECUTOR_CONTAINER, _threadPoolContainer); _servletContext.setAttribute( ServletContextKeyEnum.LOGIC_THREADPOOL_NAME, ThreadPoolType.LOGIC_THREADPOOL.name()); Set<Class<?>> allClass = ClassUtil.getClasses(packages); sessionListening(allClass); addEventListeners(allClass); webStartListening(allClass); }