官术网_书友最值得收藏!

Java's nonblocking I/O

Java NIO (New IO) is a nonblocking I/O API for Java. This NIO is an alternative to the standard Java I/O API. It provides abstractions such as channels, buffers, and selectors. The idea is to provide an implementation that can use the most efficient operations provided by the operating system, as shown in the following screenshot:

A channel is just a bidirectional I/O stream. A single thread can monitor all the channels an application has opened. Data arriving at any channel is an event, and the listening thread is notified of its arrival.

The selector uses event notification: a thread can then check whether the I/O is complete without any need for blocking. A single thread can handle multiple concurrent connections.

This translates into two primary benefits:

  • Overall, you would need fewer threads. As a thread has a memory footprint, the memory management would have less overhead.
  • Threads could do something useful when there is no I/O. This opens up the possibility of optimization, as threads are a valuable resource.

The Netty framework (https://netty.io/) is an NIO-based client-server framework. The Play framework is a high-performance, reactive web framework based on Netty.   

主站蜘蛛池模板: 陆丰市| 济宁市| 贡嘎县| 铜山县| 清苑县| 中山市| 普安县| 通江县| 甘德县| 盐池县| 德钦县| 湖北省| 荃湾区| 长沙县| 衡阳县| 苏尼特右旗| 隆子县| 哈巴河县| 松桃| 五家渠市| 云南省| 清流县| 灵台县| 连云港市| 建水县| 集安市| 清镇市| 洪雅县| 遂昌县| 云霄县| 上犹县| 北流市| 宁南县| 华亭县| 大理市| 通城县| 六盘水市| 秦安县| 门头沟区| 连南| 扶风县|