Java Web services: What's not to like?

Java offers end-to-end, top-to-bottom, client/server solutions

1 2 Page 2
Page 2 of 2

But with CPU performance optimized, the major bottleneck became the I/O subsystem. The new I/O package, java.nio, addresses that bottleneck.

As a result of efforts led by Sun Senior Staff Engineer Mark Reinhold, the new I/O package available in JDK 1.4 provides several major improvements in I/O performance and functionality:

Memory-mapped I/O

Graphic cards and other high-speed devices need direct memory access so no time is wasted copying data between buffers. Previously, Java's virtual machine was isolated from such optimizations, but the new I/O package provides that capability.

A demo shown during Green's keynote Monday morning simulated a plane flying over the Grand Canyon. Using 300 MB of LandSat data and the old I/O package, the plane lurched forward for a few feet, paused in mid-air, waited for a second, and then lurched forward again. Realtime it was not. When the demo shifted to use the memory-mapped I/O in the new I/O package, eliminating the copies from the graphics buffer, the balky, halting bursts of movement magically turned into a smooth flight. It wasn't a jet-engine fighter plane, mind you, but more of a prop-engine Cessna. Still, it smoothly banked and glided over the landscape in an impressive simulation of the real thing.

Nonblocking I/O

The lack of nonblocking I/O has proved to be a major sore point for server-side performance. With nonblocking I/O, the platform looks to see if any data can be read or written and, if not, the program moves on. With blocking I/O, by contrast, the thread is forced to sit and wait for data to appear before the program can proceed. This produces nightmares for multiclient server applications. It means you must dedicate a thread for each user, which quickly consumes memory and adds runtime overhead.

With nonblocking I/O, a single thread can handle I/O from thousands of clients. That makes it possible to write scalable applications that can handle large volumes of data.

Interruptible I/O

For realtime applications, the ability to safely and quickly interrupt an I/O operation is paramount -- and you've got to know how much of the interrupted I/O operation has been completed so you can restart it at the right point later. The new I/O package addresses both of these issues. When a gamer presses a key, for example, or when another factory unit arrives on a conveyor belt, the program may need to stop what it is doing and devote its attention to the new input. Interruptible I/O makes it possible to write programs that do just that.

File transfers

Finally, the new I/O package provides high-performance bulk data operations for files. For example, Reinhold's tests showed that the transfer operation can drive in a file copy that is almost twice as fast (1.96 times, to be precise) as it would have been under the old I/O package. This level of performance is close to that provided by a native compiler, which delivered a speed increase of a factor of just over two (2.16). (Given that version 1.4 is still in beta, Reinhold feels sure that performance will be even closer to native speed before the package ships.)

Each of these improvements in I/O capabilities opens up new vistas of opportunity for the Java platform, allowing it go where it has never (successfully) gone before.


The new APIs released by Sun provide a top-to-bottom, end-to-end solution for a Web services architecture. I return to the question posed in the beginning of my article: "You could always plug in a non-Java solution at any point in the architecture. But why would you want to?" The increased functionality and improved performance provided by the APIs discussed here should adequately answer that question for you.

Eric Armstronghas been programming and writing professionally since before there were personal computers. His production experience includes artificial intelligence (AI) programs, system libraries, realtime programs, and business applications in a variety of languages. He wrote The JBuilder2 Bible and authored the Java/XML programming tutorial available at

Learn more about this topic

1 2 Page 2
Page 2 of 2