Java in 2011: threaded sockets VS NIO: what to choose on 64bit OS and latest Java version?

前端 未结 5 1234
囚心锁ツ
囚心锁ツ 2020-12-23 18:46

I\'ve read several posts about java.net vs java.nio here on StackOverflow and on some blogs. But I still cannot catch an idea of when should one prefer NIO over threaded soc

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 19:07

    There is not a single "best" way to build NIO servers, but the preponderance of this particular question on SO suggests that people think there is! Your question summarizes the use cases that are suited to both options well enough to help you make the decision that is right for you.

    Also, hybrid solutions are possible too! You could hand the channel off to threads when they are going to do something worthy of their expense, and stick to NIO when it is better.

提交回复
热议问题