2018/05/07 NIO网络编程

参考:http://ifeve.com/selectors/


Selector 选择器

创建Selector:Selector.open();

在Selector中注册通道

channel.configureBlocking(false);// 设置为非阻塞模式
SelectionKey key = channel.register(selector,Selectionkey.OP_READ);


遍历SelectionKey

ServerSocketChannel

serverSocketChannel.configureBlocking(false);


猜你喜欢

转载自blog.csdn.net/xlb6179685/article/details/80227992