Question

The Java NIO Socket Framework supposedly hides the dirty details of non-blocking IO from developers, allowing them to build highly scalable applications, which can handle over 10000 incoming and outgoing sockets using only one thread.

  • Are non blocking IOs still a pain with the typical version of Java 2 SE/EE?

  • Is this framework still necessary and useful?

Thanks for your time.

Was it helpful?

Solution

Well, NIO creates an abstraction over some of the details, certainly. Non-blocking IO is still a pain to get your head around (at least, I find it is) but at least it's feasible. (Personally I prefer the .NET style of asynchronous IO, but that's a different matter.)

I usually use blocking IO: for most tasks, this is all I require and I wouldn't gain significantly by using non-blocking IO. In some cases (such as the one you mentioned) non-blocking IO is really the only way forward if you want to keep your thread down.

I recommend that you learn about it, play with it, and then use judgement to decide when to use it in production code. I wouldn't suggest starting to use it everywhere...

OTHER TIPS

Yes, NIO is very useful. NIO is also a bit hard to work with. Depending on your needs you could consider using frameworks that wrap NIO, like grizzly or mina. Grizzly is the networking part of glassfish appserver from sun Oracle.

Mina is a network application framework from Apache.org.

Personally I prefer grizzly but that's just me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top