HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

Although Java is cross-platform, its performance and quality are greatly influenced by the features of the underlying native platform. Since the Java language and environment includes concurrency and multithreading (MT) as integral components, the native operating system's multithreading model and environment will greatly influence Java applications' quality and performance on that system.

Sun's Java Virtual Machine (JVM), central to the performance and scalability of the Java Development Kit (JDK) for Solaris, is designed to take full advantage of multi-processor computing systems by using the native multithreading capabilities of Solaris. It performs bytecode interpretation using native multithreading and fast synchronization and, later this summer, will feature an improved memory system. These features provide developers with significant performance boosts required for successfully developing and deploying Java applications that deliver solid performance and fast response times under peak loads.

Java Multithreading Implementation Comparisons
Understanding the architectural advantages of one native MT environment/architecture over another is critical to an understanding of the advantages of one Java implementation over another. Since a typical JVM runtime is implemented on top of the traditional platform, a richer, architecturally superior MT platform will obviously translate to a superior Java MT environment for Java applications on that platform.

The native OS threads model greatly influences Java application performance because, on Solaris and other platforms, Java threads get mapped directly onto operating system native threads. In this sense, the Java thread model is a platform-independent abstraction on top of native threads that attempts to hide as many platform-specific details from the applications developer as possible and provide a single, cross-platform abstraction.

However, there are platform-specific differences between native Solaris threads and native threads on other platforms that affect Java threads' performance and resource consumption on each platform.

Advantages of Java Multithreading on Solaris
Java on Solaris leverages the multithreading capabilities of the operating system kernel while allowing developers to create powerful Java applications using thousands of user-level threads, if needed, for multiprocessor or uniprocessor systems through a very simple programming interface.

The Java on Solaris environment supports the many-to-many threads model. As illustrated in Figure 1, the Solaris two-level architecture separates the programming interface from the implementation by providing an intermediate layer, called lightweight processes (LWPs). LWPs allow application developers to rapidly create very fast and cheap threads through a portable application-level interface. Developers simply write applications using threads. The runtime environment, as implemented by a threads library, multiplexes and schedules runnable threads onto "execution resources," the LWPs.

Figure 1
Figure 1:

Individual LWPs operate like virtual CPUs that execute code or system calls. LWPs are dispatched separately by the kernel, according to scheduling class and priority, so they can perform independent system calls, incur independent page faults and run in parallel on multiple processors. The threads library implements a user-level scheduler that is separate from the system scheduler. User-level threads are supported in the kernel by the kernel-schedulable LWPs. Many user threads are multiplexed on a pool of kernel LWPs.

Solaris threads provide an application with the option to bind a user-level thread to an LWP or to keep a user-level thread unbound. Binding a user-level thread to an LWP establishes an exclusive connection between the two. Thread binding is useful to applications that need to maintain strict control over their own concurrency, such as those that require real-time response.

Since most Java applications would not require it, there is no Java API to perform the binding. If required, a Solaris native method call can be made to perform the binding. Therefore, all Java threads are unbound by default. Unbound user-level threads defer control of their concurrency to the threads library, which automatically expands and shrinks the pool of LWPs to meet the demands of the application's unbound threads

The Solaris two-level model delivers unprecedented levels of flexibility for meeting many different programming requirements. Certain programs, such as window programs, demand heavy logical parallelism. Other programs, such as matrix multiplication applications, must map their parallel computation onto the actual number of available processors. The two-level model allows the kernel to accommodate the concurrency demands of all program types without blocking or otherwise restricting thread access to system services.

Java on Solaris
Solaris 2.6 is bundled with Sun's native-threaded Java Virtual Machine 1.1 and includes a Just-In-Time (JIT) compiler. Working in conjunction with the JVM, the JIT Compiler for Solaris recognizes method compilation opportunities and serves to reduce bytecode interpretation overhead.

Because the Solaris JVM uses Solaris native threads, which provide multiprocessor support and true application concurrency to Java applications, Java threads become true operating system threads and provide the following benefits:

  • Java threads run in parallel, providing much greater performance for parallelized Java applications on multiprocessor machines.
  • Java threads harness true operating system concurrency, providing greater performance for multithreaded Java applications on both multiprocessors and uniprocessors.
  • Java applications interoperate with existing multithreaded applications in the Solaris environment.
  • The Solaris JVM is fully compatible with the Java Developer Kit 1.1 from JavaSoft and includes a JIT compiler, which substantially increases Java application performance.
The Java on Solaris design uses system resources efficiently as needed. Applications can have thousands of threads with minimal thread-use overhead. Threads execute independently, share process instructions and share data transparently with the other threads in a process. Threads also share most of the operating system state of a process, can open files and permit other threads to read them and allow different processes to synchronize with each other in varying degrees.

Evaluating Multithreading Capabilities with Real-World Application
While benchmarks can be a valuable tool to assess the performance and stability of an application, the true test is in real-world implementation.

The latest in JVM technology for Solaris is currently being evaluated as part of an early access program by several real-world Internet applications, including Vitria's BusinessWare application integration software and Volano's VolanoChat, which allows Web developers and businesses to create easily customized chat rooms for their public Websites and corporate intranets.

As a result, these highly threaded, highly networked, multiuser applications are realizing tremendous gains in Java performance, further demonstrating that the Java on Solaris threading model delivers the best combination of speed, concurrency, functionality and kernel resource utilization.

Because of the flexible manner in which the Solaris Java Virtual Machine maps Java threads to its kernel, there are no predefined limits on the number of threads that can be used per application, according to John Neffenger, CTO, Volano LLC. "We have reason to believe that the new version of the Solaris JavaVirtual Machine coming out from Sun later this summer will be the platform with all the speed, scalability, and stability that Java deserves."


All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.