Is Java NIO2 API a replacement for writing a single threaded muxed server with NIO?

I am learning how to use NIO to write dirt (I have not excluded higher level libraries, but I would like to learn low level operations as well).

In my reading, I learned about NIO2. Since I am using Java 7 for this project, I am already wondering if the NIO operations that I will be using to create a single threaded multiplexed server will not be superseded in NIO2, i.e. perhaps simplified. As far as I can tell the relevant part of NIO2 for me is its asynchronous classes. However, I am not experienced enough to know if they are needed or just another abstraction that I do not necessarily need in lieu of a basic multiplexer.

+3


source to share


2 answers


perhaps easier.

IMHO NIO2 is more complex than NIO like NIO, more complex than normal IO.

It supports asynchronous I / O calls, but they are much more difficult to use than. NIO or regular IO



If you have Inifiniband, NIO2 can give you lower latency and higher bandwidth. If you have plain Ethernet, I haven't found it pretty much.

If you want simplicity, use regular IO.

+3


source


It is an alternative, not a replacement, using a different programming model. I would not say that it is much easier, if at all. If you want simplicity use java.net and streams.



+1


source







All Articles