NIO or New I/O is the second I/O system, it provides the different way of working with I/O than the standard I/O API's. It is an alternative IO API for Java (from Java 1.4).
Difference between Blocking and Non-blocking I/O
Difference between Blocking and Non-blocking I/O
- Blocking IO wait for the data to be write or read before returning. Java IO's various streams are blocking. It means when the thread invoke a write() or read(), then the thread is blocked until there is some data available for read, or the data is fully written.
- Non blocking IO does not wait for the data to be read or write before returning. Java NIO non- blocking mode allows the thread to request writing data to a channel, but not wait for it to be fully written. The thread is allowed to go on and do something else in a mean time.