We know that the bio of java is a request corresponding to a thread, so can java nio understand that a request corresponds to a channel?

recently, I have been learning about java nio, which has been a bit strange. There is such a common code in nio programming

.
for(xxxxxxx){
   if(selectionKey.isAcceptable()){
       ServerSocketChannel ssc = (ServerSocketChannel) selectionKey.channel();
       SocketChannel socketChannel = ssc.accept();
       socketChannel.configureBlocking(false);
       socketChannel.register(selector,SelectionKey.OP_READ);
    }
    f(selectionKey.isReadable()){
       .......
    }
}

Loop scan the state of the channel. When the channel accept, a new channel socketChannel, will be generated and then the listening event will be specified. Such a tcp connection will form a channel,. Ask whether this is understood

.

it is not feasible for you to understand it only at the code level, you have to combine the code with the network model provided by the operating system to understand it.


1. Bio is a request. A new thread is created to process
2, but nio is not a request corresponding to a channel, but a tcp connection corresponding to a channel.

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e449a6-43a42.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e449a6-43a42.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?