Java NiO Plain English description (i)

Source: Internet
Author: User


Java NiO is basically a common component,Selector,channel,buffer. These three, the other can be used when the reference on it.


Look at a book, the basic knowledge of the first three chapters or four chapters, the rest, the actual production used to see it.


Plain English explains these three important words.

Channel:

In the Java NIO, the channel is actually used for transmission, or pipe, is a tool, can compare the IO in the flow, very similar. But the flow in IO is one-way, but the channel channel is bidirectional, that is, the passage can be read or written inside. This channel deals with buffer a lot, and then with NIO, the reading data is the channel that reads the data into buffer, then the application then reads the data from buffer. Writing data is when the application writes data to buffer, and then Chanel writes the data to the IO device, which is the interactive process


Buffer

When buffer is used to interpret buffers, and when the channel is introduced, it is said that the data is in the buffer, reading the data is read into the buffer first, and then read the data from buffer. The libraries in NiO manipulate data in such a way that they do not read and write data in the channel. There are three important states in the buffer: Position,limit,capacity, which is described in the next section, here is not much to introduce.


Selector

Commonly used as a selector, I explain it as a listener, to listen to one or more channels, the channel can be interested in the operation to register to selector, such as read,write,connect,accept, and then selector responsible for monitoring. It is a single thread to handle these operations, single thread has the benefit of a single-threaded, the advantage is that you can avoid thread switching between threads, so the meeting will be very large. A basic sentence indicates that this selector is used to manage multiple channels.



Welcome the old driver to correct, put forward better narration and opinion.


This article is from the "no kuibu to thousands of Miles" blog, please be sure to keep this source http://shangdc.blog.51cto.com/10093778/1955793

Java NiO Plain English description (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.