NonStop Server for Java 7.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 for thread 0 and thread 1 as follows:
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 format:
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
The Java runtime supports a simple, deterministic, scheduling algorithm known as fixed-priority
scheduling. The Java runtime does not time-slice. For the NonStop system, the thread-scheduling
algorithm is not preemptive; that is, a thread continues to run until it explicitly yields or otherwise
causes a yield by invoking a blocking operation on the thread. When a thread gives up control,
the runnable threads of the highest priority are run in first-in-first-out order. A lower priority thread
is run (also in first-in-first-out order) only when no runnable threads of a higher priority are available.
NSJ7 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 gets 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.
• 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.
If the specified value of T is 0, the value is time-sliced to 40.
42 Implementation specifics










