solution for IO operations; ! Direct to native buffers for IO operations that do not require any kind of CPU interaction to be copied over; ! Asynchronous model, so you don’t have to waste thread time sleeping;
take time to finish; ! Copying memory bounded buffers from one place to the other is a definite way to kill the Garbage Collector; ! Every single thread waiting for an IO operation counts for the thread scheduler, consumes memory and stack resources;
always talking to servers, most of their time they are just idle; ! Having one thread per client means this thread is parked most of the time, but still consuming resources; ! If you have thousands of clients, having thousands of threads is not an option in commodity hardware (and not even in specialized hardware);
(per CPU thread) waiting for events to happen; ! Everyone consumes work from a (possibly bounded) queue ; ! There is time wasted in sleep calls, everyone is CPU bound as much as possible;
library is rather complicated to handle directly for socket servers; ! Most socket servers run in a request-response cycle with a specific message format; ! And then we have NIO frameworks to do our job;
venerable Mina library; ! Builds upon the concepts defined by Mina, you have encoders, decoders, an execution model and the handler that receives messages; ! Hides most of the complexity of building a NIO client/ server from your code, you only have to care about receiving messages and working with them;