This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2021.
The Atomics.isLockFree() static method is used to determine whether the Atomics methods use locks or atomic hardware operations when applied to typed arrays with the given element byte size. It is intended as an optimization primitive, so that high-performance algorithms can determine whether to use locks or atomic operations in critical sections. If an atomic primitive is not lock-free, it is often more efficient for an algorithm to provide its own locking.
console.log(Atomics.isLockFree(3)); // 3 is not one of the BYTES_PER_ELEMENT values // Expected output: false console.log(Atomics.isLockFree(4)); // 4 is one of the BYTES_PER_ELEMENT values // Expected output: true
Atomics.isLockFree(size)
sizeThe size in bytes to check.
A true or false value indicating whether the operation is lock free.
true if size is 4, because all known platforms support 4-byte atomic operations.false if the given size is not one of the BYTES_PER_ELEMENT property of integer TypedArray types.Atomics.isLockFree(1); // true (platform-dependent) Atomics.isLockFree(2); // true (platform-dependent) Atomics.isLockFree(3); // false Atomics.isLockFree(4); // true Atomics.isLockFree(5); // false Atomics.isLockFree(6); // false Atomics.isLockFree(7); // false Atomics.isLockFree(8); // true (platform-dependent)
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
isLockFree |
68 | 79 | 78 | 55 | 15.2 | 89 | 79 | 63 | 15.2 | 15.0 | 89 | 15.2 | 1.0.0 | 1.0 | 8.10.0 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree