Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eef847e

Browse files
书写更正
1 parent 92a9f41 commit eef847e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎docs/java/BIO-NIO-AIO.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ NIO 通过Channel(通道) 进行读写。
202202

203203
通道是双向的,可读也可写,而流的读写是单向的。无论读写,通道只能和Buffer交互。因为 Buffer,通道可以异步地读写。
204204

205-
#### 4)Selectors(选择器)
205+
#### 4)Selector (选择器)
206206

207207
NIO有选择器,而IO没有。
208208

209209
选择器用于使用单个线程处理多个通道。因此,它需要较少的线程来处理这些通道。线程之间的切换对于操作系统来说是昂贵的。 因此,为了提高系统效率选择器是有用的。
210210

211-
![一个单线程中Slector维护3个Channel的示意图](https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-2/Slector.png)
211+
![一个单线程中Selector维护3个Channel的示意图](https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-2/Slector.png)
212212

213213
### 2.3 NIO 读数据和写数据方式
214214
通常来说NIO中的所有IO都是从 Channel(通道) 开始的。
@@ -273,8 +273,7 @@ public class NIOServer {
273273

274274
if (key.isAcceptable()) {
275275
try {
276-
// (1)
277-
// 每来一个新连接,不需要创建一个线程,而是直接注册到clientSelector
276+
// (1) 每来一个新连接,不需要创建一个线程,而是直接注册到clientSelector
278277
SocketChannel clientChannel = ((ServerSocketChannel) key.channel()).accept();
279278
clientChannel.configureBlocking(false);
280279
clientChannel.register(clientSelector, SelectionKey.OP_READ);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /