After the two posts about garbage collection (basic and advanced) I started receiving questions regarding the works of the GC, and tips on how to use it properly. This post will be devoted to that subject, with some of the questions asked brought into highlight and answered using a lot of information coming from a great presentation Sun gave on the subject and with some knowledge acquired from the previous posts’ research material.
This post is all about data flow in the “New I/O” framework. The data flow mechanism in NIO is essentially different from the “old” IO. There are no decorators to data, and the entire framework revolves around getting one thing done, and done really well: transferring data from an external source into the application or vice versa. In the last post I’ve described the buffers and put some emphasis on a couple of them. In this one, I’ll discuss the channels, which are the equivalents of the streams in the old IO, and the selector idea, which is taken from low-level languages such as C and brought into Java to boost performance.
The Java NIO package is all about performance. That’s why, through this post, the word performance is going to be repeated often, showing where the NIO package increases your application’s throughput. It’s important to note that the “old IO”, the java.io package, is not bad to use and some features of it are not covered by NIO at all: however, in many situations involving data flow, the NIO package provides significantly faster IO operations.