@@ -0,0 +1,1185 @@
+package edu.ouc.reactor;%0D%0A%0D%0Aimport java.nio.channels.SelectableChannel;%0D%0Aimport java.util.concurrent.atomic.AtomicInteger;%0D%0A%0D%0Aimport org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A%0D%0Apublic class ReactorPool %7B%0D%0A%09%0D%0A%09private static final Logger LOG = LoggerFactory.getLogger(ReactorPool.class);%0D%0A%09%0D%0A%09private Reactor%5B%5D reactors;%0D%0A%09%0D%0A%09private NioChannel handler;%0D%0A%09%0D%0A%09private AtomicInteger index = new AtomicInteger();%0D%0A%09%0D%0A%09private final int DEFAULT_THREADS = Runtime.getRuntime().availableProcessors() * 2;%0D%0A%09%0D%0A%09public ReactorPool ()%7B%0D%0A%09%09this(0);%0D%0A%09%7D%0D%0A%09public ReactorPool(int nThreads)%7B%0D%0A%09%09if(nThreads %3C 0)%7B%0D%0A%09%09%09throw new IllegalArgumentException(%22nThreads must be nonnegative number%22);%0D%0A%09%09%7D%0D%0A%09%09if(nThreads == 0)%7B%0D%0A%09%09%09nThreads = DEFAULT_THREADS;%0D%0A%09%09%7D%0D%0A%09%09reactors = new Reactor%5BnThreads%5D;%0D%0A%09%09for(int i = 0; i %3C nThreads; i++)%7B%0D%0A%09%09%09reactors%5Bi%5D = new Reactor();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A    public void register(SelectableChannel channel, int interestOps, Object attachment) %7B%0D%0A        next().register(channel, interestOps, attachment);%0D%0A    %7D%0D%0A%09public Reactor next()%7B%0D%0A%09%09return reactors%5Bindex.incrementAndGet() %25 reactors.length%5D;%0D%0A%09%7D%0D%0A%0D%0A%09public NioChannel getHandler() %7B%0D%0A%09%09return handler;%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

add Reactor Pool