Pull to refresh

Comments 17

Глаз режет расшифровка nio как new io. С чего бы это, если nio означает non-blocking io?
Вот это поворот, всю жизнь думал, что это new io (и мысленно ругал, ибо что потом будет, newest io и тд?)
Нет, в джаве это именно расшифровыется как new io. Вот полное название JSR 51: New I/O APIs for the JavaTM Platform. В седьмой добавили NIO.2 JSR 203: More New I/O APIs for the JavaTM Platform («NIO.2»)
Спасибо за комментарий. Старое доброе правило работает: «Если сомневаешься, то смотри стандартную документацию»
nbio тогда назывался бы.
Версию new IO предлагает также Греберт Шилдт (Java Полное руководство, у меня 8е идание стр. 641)
Java IO было с первых версий, Java NIO появилось только с 1.4, отсюда можно вывести, что Новая
ByteBuffer buffer = ByteBuffer.allocate(48);
int bytesRead = inChannel.read(buffer);
while(! bufferFull(bytesRead) ) {
bytesRead = inChannel.read(buffer);
}


are you kidding me? Never use this approach, it's way to nowhere. You need to better learn what selector is and how to use non-blocking operations.
You are right! But in this article this source code is not a tutorial of using Selector, it is an example of wrong desigh approach. That is why before this code I wrote: «Это неэффективно и может негативно сказаться на дизайне программы. Например:». The translation of this phrase is — «It isn't effective and can have a negative impact on app design. For example:»
Oh, I've missed it :) But I still think it's not good way to present non-bloking part of library. It's better to say that we could do something in blocking mode but in some cases it's bad solutions and at this time we can use non-bloking IO and bla bla bla.
I'm writing on english just because I don't have rus keyboard at work and I still can read russian :)
Вот интересно что будет если прибудут сразу три поезда? Куда кинется сотрудник вокзала?
В целом же — в каждом из вариантов свои проблемы. IO тратит больше ресурсов на сетевую подсистему и меньше на обработку данных, NIO — наоборот.
Sign up to leave a comment.

Articles