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

前端 未结 5 1239
囚心锁ツ
囚心锁ツ 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:18

    That seems right to me, except for the part about Java limiting the number of threads – that is typically limited by the OS it's running on (see How many threads can a Java VM support? and Can't get past 2542 Threads in Java on 4GB iMac OSX 10.6.3 Snow Leopard (32bit)).

    To reach that many threads you'll probably need to adjust the stack size of the JVM.

提交回复
热议问题