NonStop Server for Java 7.0 Programmer's Reference
NOTE: This option is an experimental option and HP does not recommend this
option to be used in the production environment.
Threading considerations for Java code
A thread-aware function blocks only the thread calling that function, rather than blocking the entire
process. NSJ7 uses the PUT library in which all I/O are nonblocking.
JToolkit provides a thread-aware API for performing I/O to Enscribe files, $RECEIVE, and Pathway
servers by using Pathsend procedure calls. For more information, see JToolkit for Java API Reference
Pages.
Thread-aware I/O Support
In NSJ7, I/O operators are always nonblocking for OSS files. Earlier versions of NSJ, provided
an option —Dnsk.java.nonblocking to switch between the blocking and nonblocking I/O
operation. This option is no longer supported on NSJ7.
Threading considerations for native code
NSJ7 supports only the POSIX User Thread library. As a result, the following issues must be
considered when migrating to NSJ7:
• The JNI or C/C++ code in a Java application that uses the Pthread API must be ported to use
the _PUT_MODEL_ as described in the Open System Services Programmer's Guide.
• The PUT library Z/YPUTDLL must be linked statically to the application. This impacts JNI
applications that currently (pre-NSJ7) load ZSPTDLL dynamically.
In NSJ7, the application must be linked with Z/YPUTDLL depending on whether it is a 32–bit or
64–bit application.
If a user native library linked into Java creates a thread, non thread-aware operations executed in
the user library might impact the operation of the Java virtual machine. If the user library creates
multiple user threads, the program needs to be more careful to ensure that the operations performed
in the user threads are thread-safe on the NonStop system. All threaded code preferably written
in Java rather than native code.
You need to consider the following issues when using threads in native code linked to a Java
program on a NonStop system:
• NSJ7 uses the POSIX User Thread Library from the standard location.
Your code must include the POSIX User Thread header files in the standard location. You must
use the header files from the standard location /usr/include/.
• Creating a thread for a task does not make the task run faster.
The NonStop system does not have an implementation of native threads since threads run at
a user level. Even on a multiprocessor NonStop system, all native threads (user threads) in a
process are executed in the same processor as the process. If you create user threads whose
only purpose is to run a certain task, the thread creation overhead makes the task run slower
than the same task being performed without creating the thread.
• The thread-scheduling algorithm is not preemptive.
A thread executes until it explicitly yields. For more information, see discussion of “Thread
scheduling” (page 41).
• In a very long-running, CPU-intensive thread, having your native code occasionally invokes
the yield() method which allows timer and I/O completions to be detected. Invocation of
Multi-threaded programming 43










