网络编程 -- RPC实现原理 -- NIO多线程 -- 迭代版本V1
Posted limeOracle
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了网络编程 -- RPC实现原理 -- NIO多线程 -- 迭代版本V1相关的知识,希望对你有一定的参考价值。
啦啦啦
V1——设置标识变量selectionKey.attach(true);只处理一次(会一直循环遍历selectionKeys,占用CPU资源)。
(由于key没有清除,依旧在selectionKeys中存在,遍历时依旧会检测到对应事件,除非socket关闭或调用selectionKey.cancel();清除对应事件)
Class : Service
package lime.pri.limeNio.optimize.socket2; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.Iterator; import java.util.Set; public class Service { public static void main(String[] args) throws IOException, InterruptedException { ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.bind(new InetSocketAddress(9999)); serverSocketChannel.configureBlocking(false); Selector selector = Selector.open(); serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT); while (true) { System.out.println(Thread.currentThread() + " 监听端口@9999,等待客户端连接..."); int n = selector.select(); System.out.println(Thread.currentThread() + " 事件就绪通道个数 : " + n); Set<SelectionKey> selectedKeys = selector.selectedKeys(); Iterator<SelectionKey> iterator = selectedKeys.iterator(); while (iterator.hasNext()) { SelectionKey selectionKey = iterator.next(); iterator.remove(); if (selectionKey.isValid() && selectionKey.isAcceptable()) { System.out.println(Thread.currentThread() + " -- -- -- 处理Acceptable事件"); ServerSocketChannel ssc = (ServerSocketChannel) selectionKey.channel(); SocketChannel sc = ssc.accept(); sc.configureBlocking(false); sc.register(selector, SelectionKey.OP_READ); } else if (selectionKey.isValid() && selectionKey.isReadable()) { if (null == selectionKey.attachment()) { System.out.println(Thread.currentThread() + " -- -- -- 处理Readable事件"); selectionKey.attach(true); RequestProcessor.proceess(selectionKey, selector); }else{ System.out.println(Thread.currentThread() + " -- -- -- IO Readable 处理中..."); } } else if (selectionKey.isValid() && selectionKey.isWritable()) { if (null == selectionKey.attachment()) { System.out.println(Thread.currentThread() + " -- -- -- 处理Writable事件"); selectionKey.attach(true); ResponseProcessor.proceess(selectionKey, selector); }else{ System.out.println(Thread.currentThread() + " -- -- -- IO Writable 处理中..."); } } } } } }
Class : RequestProcessor
package lime.pri.limeNio.optimize.socket2; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class RequestProcessor { private static ExecutorService exec = Executors.newFixedThreadPool(5); public static void proceess(final SelectionKey selectionKey, final Selector selector) { exec.submit(new Runnable() { public void run() { try { ByteBuffer byteBuffer = ByteBuffer.allocate(1024); byteBuffer.clear(); SocketChannel sc = (SocketChannel) selectionKey.channel(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); while(sc.read(byteBuffer) != -1){ bos.write(byteBuffer.array()); byteBuffer.clear(); } System.out.println(Thread.currentThread() + " 客户端( " + sc.getRemoteAddress() + " ) 请求 : " + bos.toString()); sc.register(selector, SelectionKey.OP_WRITE); } catch (Exception e) { } } }); } }
Class : ResponseProcessor
package lime.pri.limeNio.optimize.socket2; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.Date; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ResponseProcessor { private static ExecutorService exec = Executors.newFixedThreadPool(5); public static void proceess(final SelectionKey selectionKey, final Selector selector) { exec.submit(new Runnable() { public void run() { try { String response = "服务端响应 : " + new Date().toString(); ByteBuffer byteBuffer = ByteBuffer.wrap(response.getBytes()); SocketChannel sc = (SocketChannel) selectionKey.channel(); sc.write(byteBuffer); sc.close(); } catch (IOException e) { } } }); } }
Class : Client
package lime.pri.limeNio.optimize.socket2; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; public class Client { public static void main(String[] args) throws IOException { for (int i = 0; i < 10; i++) { new Thread() { @Override public void run() { try { SocketChannel socketChannel = SocketChannel.open(); socketChannel.connect(new InetSocketAddress("127.0.0.1", 9999)); socketChannel.write(ByteBuffer.wrap("Query Date".getBytes())); socketChannel.shutdownOutput(); ByteBuffer byteBuffer = ByteBuffer.allocate(1024); socketChannel.read(byteBuffer); System.out.println(Thread.currentThread() + " " + new String(byteBuffer.array())); socketChannel.close(); } catch (IOException e) { } } }.start(); } } }
Console : Server
Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 1 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 1 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 1 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 1 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 6 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[pool-1-thread-1,5,main] 客户端( /127.0.0.1:4039 ) 请求 : Query Date Thread[main,5,main] -- -- -- 处理Readable事件 Thread[pool-1-thread-2,5,main] 客户端( /127.0.0.1:4038 ) 请求 : Query Date Thread[pool-1-thread-3,5,main] 客户端( /127.0.0.1:4041 ) 请求 : Query Date Thread[main,5,main] -- -- -- 处理Readable事件 Thread[pool-1-thread-4,5,main] 客户端( /127.0.0.1:4037 ) 请求 : Query Date Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 7 Thread[main,5,main] -- -- -- 处理Writable事件 Thread[pool-1-thread-5,5,main] 客户端( /127.0.0.1:4039 ) 请求 : Thread[pool-1-thread-2,5,main] 客户端( /127.0.0.1:4036 ) 请求 : Query Date Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- 处理Writable事件 Thread[pool-1-thread-3,5,main] 客户端( /127.0.0.1:4042 ) 请求 : Query Date Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[pool-1-thread-1,5,main] 客户端( /127.0.0.1:4036 ) 请求 : Thread[main,5,main] 事件就绪通道个数 : 8 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- 处理Writable事件 Thread[pool-1-thread-4,5,main] 客户端( /127.0.0.1:4043 ) 请求 : Query Date Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 9 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[pool-1-thread-5,5,main] 客户端( /127.0.0.1:4040 ) 请求 : Query Date Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[pool-1-thread-2,5,main] 客户端( /127.0.0.1:4044 ) 请求 : Query Date Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Acceptable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[pool-1-thread-3,5,main] 客户端( /127.0.0.1:4045 ) 请求 : Query Date Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Readable事件 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[pool-1-thread-1,5,main] 客户端( /127.0.0.1:4045 ) 请求 : Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- 处理Writable事件 Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 10 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2 Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] -- -- -- IO Writable 处理中... Thread[main,5,main] 监听端口@9999,等待客户端连接... Thread[main,5,main] 事件就绪通道个数 : 2Netty_02_高性能的NIO框架