Java NiO non-clogging technology is actually to take the reactor mode, or the Observer mode for us to monitor the I/O port, if there is content in, will automatically notify us, so that we do not have to open multiple threads death, from the outside world, achieve a smooth I/O read and write, not blocked.
NIO has a major class selector, which resembles an observer, so long as we tell selector what we need to know, we go on to do something else, and when something happens, he informs us, returns a group of Selectionkey, We read these keys, we get the socketchannel we just registered, and then we read the data from the channel, and we can read the packet, and then we could process the data.
Selector internal principle is actually doing a polling access to the registered channel, constantly polling (currently this algorithm), once polling to a channel to register things happen, such as the data came, he will stand up report, hand over a key, Let's use this key to read the channel's contents.
NiO in Java