how to choose java nio vs io?

前端 未结 7 1488
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 07:12

As we had known, If we want to use traditional IO to construct server, it must block somewhere, so we had to use loop or one thread one socket mode, So nio seem it is better

7条回答
  •  清酒与你
    2020-12-24 07:50

    If you want non-blocking IO, NIO is not the better choice—it's the only choice in Java. Keep in mind that people still use the old IO regularly because it is way simpler to code against. NIO API is quite raw and is more of an enabling low-level technology than a client-side API. I suggest using NIO through an API that provides a simpler interface to the problems you want to solve using non-blocking IO.

提交回复
热议问题