Ive been reading for the past few days about the difference between io and nio when building a java socket server. for my use i need a server which can run lots of connections and ion supposed to do the trick.
My only fear is that it a bit slower and a bit harder to implement instead of running a thread for each connection. so i thought why dont i use the same easiness of threads and the logic of java.nio and build a server has a thread which checks all the open connection and when ever there is a new event, it will open a new thread for handing it. i think in that way im enjoying both of the worlds… what do u suggest?
Ive been reading for the past few days about the difference between io and
Share
NIO almost entirely relies on JNI, so if you want to implement it again, you’ll actually have to write loads of C/++ and OS API interface code.
I think the existing Java implementations are already quite good. For example, the Selector class wraps the system call for waiting on multiple file descriptors. There’s hardly anything you can do to improve the efficiency of that.