| Aspect | Blocking I/O (java.io) | NIO (java.nio) |
|---|---|---|
| Model | Thread waits on read/write | Channel + Buffer; selector multiplexes |
| Strength | Simple code, JDBC-friendly | Many idle connections, one thread |
| Risk | Thread explosion at scale | Complex state machines, partial reads |
Model
Blocking I/O (java.io)Thread waits on read/writeNIO (java.nio)Channel + Buffer; selector multiplexesStrength
Blocking I/O (java.io)Simple code, JDBC-friendlyNIO (java.nio)Many idle connections, one threadRisk
Blocking I/O (java.io)Thread explosion at scaleNIO (java.nio)Complex state machines, partial reads
Interview trap
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Test yourself
Answer these before moving on — recall is what makes it stick.