Is Java's NIO2 API a replacement for writing a single-threaded multiplexed server with NIO?

StackOverflow https://stackoverflow.com/questions/14592137

문제

I'm learning how to use NIO to write a mud (I have not ruled out higher-level libraries, but I would like to learn the low-level operations as well).

In my reading I've learned about NIO2. Since I'm using Java 7 for this project already I'm wondering if the NIO operations I would use to write a single-threaded multiplexed server are not replaced in NIO2 -- that is, perhaps made simpler. As far as I can tell the relevant part of NIO2 for me are its asynchronous classes. However I'm not experienced enough to know if these are necessary or just a different/new abstraction that I don't necessarily need in place of a basic multiplexer.

도움이 되었습니까?

해결책

perhaps made simpler.

IMHO NIO2 is as more complicated than NIO like NIO is more complicated than plain IO.

It supports asynchronous IO calls but these are much harder to use effectively than. NIO or plain IO

If you have Inifiniband, NIO2 can give you lower latency and higher throughput. If you have plain Ethernet, I haven't found it to make much difference.

If you want simplicity, use plain IO.

다른 팁

It's an alternative rather than a replacement, using a different programming model. I wouldn't say it is significantly simpler, if at all. If you want simplicity use java.net and threads.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top