Spin Loop Hint
Looking for Zing? The Azul Zing Virtual Machine is now Azul Zulu Prime Builds of OpenJDK and part of Azul Platform Prime. Learn more.
The Intel x86 processors with the SSE2 instruction set contain a new instruction
Pause that indicates that the CPU, which is currently running the thread, is effectively in a spin loop. Encountering such an indicator can help the CPU give more compute resources to other running threads by optimizing thread scheduling and thread switches. The new SpinHint java API helps the Azul Zulu Prime Builds of OpenJDK (Azul Zulu Prime JVM) to emit the x86 Pause instruction where the
spinLoopHint method is being called. It does not change the semantics of the java code in any way.
|Use the spin loop hint with caution. For additional guidance and information on this advanced tuning instruction, contact Azul Technical Support.|
To use spin loop hint with Zing do the following:
Import the package
Add a call
SpinHint.spinLoopHint()where you want to hint to the CPU that this location is a spin loop.
The example below illustrates how to use