Command-line flag:jdk-tool [-green | -native] options...where:jdk-tool is eitherEnvironment variable:
appletviewer.Green threads are the default. The command-line flags, if specified, override the setting of the% setenv THREADS_FLAG [-green | native]
The Solaris Java Development Kit includes two implementations of thread-handling software. The default threads implementation is called green threads; a native threads implementation is also available.
Native threads can provide several advantages over the default green threads implementation, depending on your computing situation. Among the benefits of using the native threads are:
- If you run Java code in a multi-processor environment, the Solaris kernel can schedule native threads on the parallel processors for increased performance. By contrast, green threads exist only at the user-level and are not mapped to multiple kernel threads by the operating system. Performance enhancement from parallelism cannot be realized using green threads.
- The native threads implementation can call into C libraries that use Solaris native threads. Such libraries cannot be used with green threads.
- When using the native threads, the VM can avoid some inefficient remapping of I/O system calls that are necessary when green threads are used.
In some instances, it may be advisable to use the default green threads. Native code that is not multithread safe (MT-safe) may not work correctly with native threads. In general, if you aren't using the native Solaris threads mechanisms directly, then you need to compile your native code with the option
-D_REENTRANTto make sure that they work correctly in a threaded environment. You may also need to use reentrant versions of certain Solaris interfaces.
Specific information concerning multithreaded programming on Solaris may be found in the Multithreaded Programming Guide of the Solaris Software Developer AnswerBook. This information is also available on the
It is possible that thread-synchronization bugs in code that you run may be hidden when using green threads, but may manifest themselves when run under native threads. You should consider this possibility if your code runs differently under the two threads packages.
All the tools in the Solaris Java Development Kit use green threads by default. To specify that native threads should be used, you can set the
THREADS_FLAGenvironment variable:% setenv THREADS_FLAG native
You can revert to use of green threads by setting
THREADS_FLAGto the value
green:% setenv THREADS_FLAG green
You can also select the thread option by using the
-greencommand-line flag with the JDK tools. The threads flag must be the first option specified on the command line.
The command-line flags can be used as in these examples:% java -native mypkg.MyClass % appletviewer -green MyApplet.html
The command-line flags override the setting of the