Atomics.pause()
The Atomics.pause() static method provides a micro-wait primitive that hints to the CPU that the caller is spinning while waiting on access to a shared resource. This allows the system to reduce the resources allocated to the core (such as power) or thread, without yielding the current thread.
pause() has no observable behavior other than timing. The exact behavior is dependent on the CPU architecture and the operating system. For example, in Intel x86, it may be a pause instruction as per Intel's optimization manual. It could be a no-op in certain platforms.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 133 | 133 | 137 | 18.4 | 133 | 18.4 | |
Syntax
// Atomics.pause() example
// See MDN Web Docs for details Live demo
Check Atomics.pause support
Detect whether Atomics.pause is available in the current runtime.
Call Atomics.pause safely
Invoke Atomics.pause only when the API exists.
Use a guarded spin helper
Build a tiny helper that prefers Atomics.pause during a retry loop.
Use cases
-
Spin-wait tuning
Improve busy loops that coordinate threads over shared memory in latency-sensitive code.
-
Lock-free experiments
Use it in carefully profiled concurrency primitives where tiny timing behavior matters.
Cautions
- Most application code should not use spin waits at all; message passing and higher-level coordination are usually safer.
- Performance hints need profiling because they are not guaranteed to help every workload.
Accessibility
- This feature has no direct accessibility behavior, but poor concurrency decisions can still damage responsiveness.
- Only low-level performance code with a measured need should reach for this API.