/** * Register {@link SelectorHandler} on all read controllers * * @param selectorHandler */ private void removeSelectorHandlerOnReadControllers(SelectorHandler selectorHandler) { if (readThreadControllers == null) return; for (ReadController readController : readThreadControllers) { readController.removeSelectorHandlerClone(selectorHandler); } }
/** Initialize the number of ReadThreadController. */ private void initReadThreads() throws IOException { // Attributes need to be shared among Controller and its ReadControllers if (attributes == null) { attributes = new HashMap<String, Object>(2); } readThreadControllers = new ReadController[readThreadsCount]; for (int i = 0; i < readThreadsCount; i++) { ReadController controller = new ReadController(); copyTo(controller); controller.setReadThreadsCount(0); readThreadControllers[i] = controller; } for (SelectorHandler selectorHandler : selectorHandlers) { addSelectorHandlerOnReadControllers(selectorHandler); } for (int i = 0; i < readThreadControllers.length; i++) { // TODO Get a Thread from a Pool instead. new Thread(readThreadControllers[i], "GrizzlyReadController-" + i).start(); } }