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

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

    I still think the context switch overhead for the threads in traditional IO is significant. At a high level, you only gain performance using multiple threads if they won't contend for the same resources as much, or they spend time much higher than the context switch overhead on the resources. The reason for bringing this up, is with new storage technologies like SSD, your threads come back to contend on the CPU much quicker

提交回复
热议问题