Understanding Java NIO
From blocking I/O in C to I/O multiplexing, the Reactor pattern, and Java implementations.
3 posts · In reading order
Understanding Java NIO (Part 1): Blocking I/O Servers in C with Processes, Threads, and Thread Pools
C implementations of blocking socket servers use a single process, multiple processes, multiple threads, and a thread pool to explain connection handling, file descriptors, and resource release. Comparing their concurrency and overhead establishes a foundation for nonblocking I/O and I/O multiplexing.
Understanding Java NIO (Part 2): I/O Multiplexing and Reactor Servers in C
Starting from the limitations of polling with nonblocking I/O, this post introduces select and epoll through C examples. It explains file descriptors, level-triggered and edge-triggered notifications, then combines connection management, I/O event handling, and a business thread pool into a Multi-Reactor server.
Understanding Java NIO (Part 3): I/O Multiplexing and the Reactor Pattern in Java, with Open-Source Framework Code Analysis
This post implements a Multi-Reactor server with Java NIO and explains how Channel, Buffer, Selector, and wakeup work together. It also covers cross-thread channel registration and dynamically adjusting read/write events, and analyzes how NIO is applied in the source code of Apache HttpClient and the Kafka client.