One of the newer features of Java as of 1.4 is non-blocking IO, yet it’s very hard to find decent documentation about it or even a simple tutorial. NIO is a very powerful feature but easy to get wrong given it’s complexity. However, James Greenfield, an engineer for Amazon, recently announced that he’d put up a tutorial for NIO, including a lot of important details of using NIO with SSL.
About
devnulled is a blog which caters to software development related issues with a pro-unix and open standards slant. devnulled has been featured on Slashdot, Digg, the Indeed Blog, O'Reilly Hacks, and del.icio.us/popular.
Brandon Harper, the author behind devnulled,
is a Software Engineer primarily working with Java but also dabbles in Python, ColdFusion, FreeBSD, and Linux. He's been
programming since age eight, professionally for over ten years, and has been been published in various industry publications and popular websites.
Brandon also enjoys music, photography, politics, command prompts, and things with wheels a wee bit much.
5 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
cool, i’ve had to make use of NIO several time over the last few years, wish i’d seen that tutorial before. thanks.
Funny you should blog about this. I’ve been spending a good deal of the last week trying to untangle NIO (the non-blocking networking part, not all the other stuff that NIO entails like memory mapping).
I found that a pretty nice package has been moved into Apache called MINA. I’ve decided that I will most likely use this for our purposes. It was previously called Netty2. If you don’t feel like struggling with a poorly documented API unnecessarily, I’d consider it. MINA is still lacking documentation, too, but the mailing list is very lively, and the examples are pretty good.
I’ve also read that under certain conditions/requirements, using BIO still wins out in performance. I’ll be darned if I remember where, but I think it was on Sun discussion boards, or maybe the IBM ones.
Yeah, I have yet to actually dive into NIO myself, but a library I’m using at the moment is NIO based as well as some other stuff in the platform I work on, so it’s been on my radar lately.
Yep. I dug into it when it was first released but I never understood the benefits fully back then. And how the world can documentation about such a nice piece of architecture as event driven communication (which bytw is hot hot hot in lighttpd, apache etc) be so crappy ?
Anyway I think most tutorials only work in windows especially the thing that a key mostly is writeable in linux will make you to hack some workarounds to not have zillions of wakeups on write events.
I will try this tutorial. I’m writing since 4 years (yet another) caching framework (which I will release on SF) and will include a nonblocking distributed server/client cache. I have a total well performing blocking solution with worker threads, traffic control etc but I want to measure the difference between a well implemented nonblocking solution compared to a blocking.
It will not be easy since serialization is involved and I think I will be needing a bunch of worker threads handling send queues. People tend to say that you always should use one thread but I’m skeptic since
the underlying operations might read a file, db or so=block.
Everywhere I read people says Serialization=not NIO. but I know it can be done since I have a stupid echo serializing server now.
Keep up the blogging about this issue I sure need it
Kindly
//Marcus
There is another good nio tutorial on java. net.