NonStop Server for Java 6.0 Programmer's Reference
}
}
On the NonStop system, the execution of threads is not time-sliced. Messages from one thread
precede those from the other thread as shown below for thread 0 and thread 1.
Thread #0, tick = 50000
Thread #0, tick = 100000
Thread #0, tick = 150000
Thread #0, tick = 200000
Thread #0, tick = 250000
Thread #0, tick = 300000
Thread #0, tick = 350000
Thread #0, tick = 400000
Thread #1, tick = 500000
Thread #1, tick = 100000
Thread #1, tick = 150000
When the SelfishRunner.java program is run with the –XX:ThreadTimeSlice option, time slicing
is enabled and the messages from one thread do not precede messages from the other threads.
Instead, the messages are displayed in the following manner:
Thread #0, tick = 50000
Thread #0, tick = 100000
Thread #0, tick = 150000
Thread #0, tick = 200000
Thread #0, tick = 250000
Thread #1, tick = 50000
Thread #1, tick = 100000
Thread #1, tick = 150000
Thread #1, tick = 200000
Thread #0, tick = 300000
Thread #0, tick = 350000
Thread #0, tick = 400000
NOTE: The NonStop Java 6.0 T2766H60^ABP release includes a beta version of the JVM-forced,
preemptive thread scheduling feature. This feature also provides an option to specify the time slice
for threads. A thread will run for the specified time slice, after which another thread will get
dispatched from the ready queue. This helps in force-yielding a thread which consumes large
processor time so that the other ready threads also get the processor time to run.
To enable preemptive user threads, use the following option:
-XX:ThreadTimeSlice[=T]
where,
T specifies the time in milliseconds.
NOTE:
• T is an optional argument.
• The default value of T is 40 milliseconds.
• The value of T can range between 0 to 32767. If the specified value of T is above 32767,
the value is time-sliced to 32767.
Threading Considerations for Java Code
A thread-aware function blocks only the thread calling that function, rather than blocking all threads
in the process. At the Java program level, the following blocking operations are thread-aware and,
therefore, block only the thread performing the operation rather than blocking all threads in Java:
• Socket I/O
• Terminal I/O
Multithreaded Programming 49










