Java: what exactly is the difference between NIO and NIO.2?

前端 未结 3 746
礼貌的吻别
礼貌的吻别 2021-01-30 00:55

I don\'t quite understand how different they are from each other so I have some inquiries regarding these two packages.

After looking around a bit on Google, it seems li

3条回答
  •  清歌不尽
    2021-01-30 01:06

    NIO.2 introduced asynchronous i/o.

    Asynchronous I/O is an approach to non-blocking i/o that is not supported by NIO.

    NIO: selectors / reactor pattern

    NIO.2: completion handlers / proactor pattern

    Thus when on Windows, NIO.2 uses I/O Completion Ports, which should boost performance. Except, nobody knows, because nobody uses Windows on the server side, and if they do, they probably do so because they are heavily invested in .net, and for that reason will most likely not consider using Java.

提交回复
热议问题