java.nio.channels.IllegalBlockingModeException
来源:互联网 发布:星际战甲网络端口 编辑:程序博客网 时间:2024/05/24 07:42
java.nio.channels.IllegalBlockingModeException
相关错误代码:
class Handler {public Handler(Selector selector, SocketChannel socketChannel) throws InterruptedException {try {SelectionKey key = socketChannel.register(selector, SelectionKey.OP_READ);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}//while (true) {//System.out.println("Handler");//Thread.sleep(1000);//}socketChannelMap.put(socketChannel.hashCode(), socketChannel);System.out.println("Handler end" + socketChannel.hashCode() + "," + socketChannelMap.size());}}发生错误语句:
SelectionKey key = socketChannel.register(selector, SelectionKey.OP_READ);错误原因:
必须设置通道为 非阻塞,才能向 Selector 注册。
解决方法:
在发生错误的语句前添加:
socketChannel.configureBlocking(false);注意参数值,false 为 非阻塞,true 为 阻塞。
阅读全文
0 0
- java.nio.channels.IllegalBlockingModeException
- java.nio.channels.IllegalBlockingModeException
- java.nio.channels.CancelledKeyException
- spark<java.nio.channels.ClosedChannelException>
- 关于hadoop的java.nio.channels.ClosedByInterruptException
- KafKa error java.nio.channels.UnresolvedAddressException
- DUBBO Caused by: java.nio.channels.ClosedChannelException
- API笔记之java.nio.channels.Selector
- API笔记之java.nio.channels.SelectionKey
- Kafka异常 java.nio.channels.ClosedChannelException
- Caused by: java.nio.channels.NotYetConnectedException: null
- java.nio.channels.FileChannel源码解读
- spark提交任务java.nio.channels.ClosedChannelException
- Java NIO (二) 通道(Channels)
- 使用java nio 时报 java.nio.channels.CancelledKeyException
- 关于nio的java.nio.channels.CancelledKeyException的解决方法
- java.sql.SQLException: Java exception: ': java.nio.channels.ClosedByInterruptException'.
- 《转载》Java 连接Kafka报错java.nio.channels.ClosedChannelExcep
- 那些年你“听不懂”的安全名词
- 有钱Python,没钱PHP,编程语言也嫌贫爱富
- iOS
- 【POJ 3281 Dining】& 网络流Dinic & 拆点
- [Kubernetes][scheduler模块源码分析]
- java.nio.channels.IllegalBlockingModeException
- Springboot之旅途
- [Geometry] Alpha Shapes
- iOS 使用QLPreviewController预览本地和网络文件
- MySql数据库链接问题ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- 分布式b2b b2c o2o电子商务云平台
- SpringBoot-Actuator-加SpringSecurity验证
- 快速用matlab求解线性规划
- 传输层TCP和UDP的区别分析与应用场景 有图有真相(转载)