Skip navigation.
Downloads | Product Documentation | Support

Using WebLogic JRockit 8.1 SDK

# Selecting and Running a Thread System

WebLogic JRockit's thread systems allow the JVM to take optimal advantage of the underlying operating system. WebLogic JRockit JVM supports two types of thread systems: native threads and thin threads. This section describes these thread systems and how to select and run them with your application. It includes information on the following subjects:

- Native Threads
- Thin Threads
- Starting the Thread System
- Choosing a Thread System

# Native Threads

This is the WebLogic JRockit JVM's default thread system. It maps Java threads directly to the operating system threads, taking advantage of the operating system's thread scheduling and load balancing policies.

# Thin Threads

Warning: Thin threads is experimental functionality in this version of WebLogic JRockit, and is not recommended for general use. This feature is subject to change without notice.

Thin threads simulate several Java threads with one (or more) native threads that represent the running program (Figure 5-1). Context switches and scheduling is done internally within WebLogic JRockit, and is therefore much light-weight than context switching done within native threads by the operating system.

Figure 5-1 Thin Threads Model

Thin threads are independent of native threads and are implemented in WebLogic JRockit JVM, thus they are not part of the operating system. This means WebLogic JRockit JVM uses less memory to perform optimized thread scheduling, thread switching, and thread synchronization. This makes it possible to run a significantly higher number of threads at a higher speed than with any other JVM.

To fully utilize system resources on a multi-processor system, WebLogic JRockit JVM is not restricted to running all Java threads in the same operating system thread. A variety of operating system threads can be used, which splits the Java threads among them. A Java thread is not bound to a specific operating system thread; it can move between them to allow for optimal load balancing.

# Starting the Thread System

Note: For information on selecting the best thread system for your application, please refer to Choosing a Thread System.

To start a thread system, include one of the options listed in Table 5-1 when you start WebLogic JRockit JVM:

Table 5-1 Options Used to Implement Threading

To Use... | Use this Option...
--- | ---
Native Threads | `-Xnativethreads` This option is the default and only needs to be specified if you are switching from native threads.
Thin Threads | `-Xthinthreads` This option is not available on IA64. Additionally, thin threads is experimental functionality in this version of WebLogic JRockit and it is recommended that you do not use it. It is subject to change at any time.

# Choosing a Thread System

This section includes some tools that will help you determine which thread system is right for your WebLogic JRockit JVM implementation. It contains a list of the pros and cons of each method and a decision matrix that will help you identify the optimal threading model.

## Pros and Cons

Table 5-2 lists the pros and cons of each thread system.

Table 5-2 Thread System Pros and Cons

Thread System | Pros | Cons
--- | --- | ---
Native Threads | Takes advantage of the operating system's thread scheduling and load balancing policies. Are standard for native applications, which relies upon the fact that each Java thread is mapped to an operating system thread of its own, this is the only model that works (both DB2 and Oracle level 2 JDBC database drivers have been known to rely upon this). On a multiprocessor system when the application has few active threads, the operating system scheduling system is better at utilizing the CPUs efficiently. | Context switching is more costly as it has to be done in the operating system instead of only in the JVM. Every Java thread consumes more resources, because it requires an operating system thread of its own.
Thin Threads | Since several Java threads are run in the same operating system thread, JRockit can perform optimized thread scheduling, thread switching, and thread synchronization with less memory. A variety of operating system threads can be used, splitting the Java threads instead of the operating system threads among them. A Java thread is not bound to a specific operating system thread, so it can move between them to allow for optimal load balancing. | Not fully supported by or tested with this version of WebLogic JRockit. Adds complexity because bridging against the operating system becomes less obvious. Requires WebLogic JRockit JVM, instead of the operating system, to schedule threads, which can negatively impact performance. Not an effective on multiprocessing systems that require a small number of threads (a few hundred or less). Not designed to run with IA64 machines.

## Thread System Selection Matrix

Because thin threads is experimental functionality and subject to change, BEA Systems recommends that you always use native threads as your threading system. However, under certain circumstances, thin threads might provide optimal performance for your WebLogic JRockit JVM implementation. Use the If... column in Table 5-3 to locate a condition that matches your implementation and select the thread system indicated in the Select this Method... column.

Table 5-3 Threading System Selection Matrix

If... | Select this Method...
--- | ---
You have a relatively small number of threads (less than 100) | Native Threads
Require a proven thread system | Native Threads
You are using an IA64 machine | Native Threads
You have in excess of a couple hundred threads | Thin Threads
You are running Linux on a single-CPU system | Thin Thread. This is because Linux threads are very expensive to use.

.