Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Atomics.isLockFree()

BaselineWidely available

TheAtomics.isLockFree() static method is used to determine whether theAtomics 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.

Try it

console.log(Atomics.isLockFree(3));// 3 is not one of the BYTES_PER_ELEMENT values// Expected output: falseconsole.log(Atomics.isLockFree(4));// 4 is one of the BYTES_PER_ELEMENT values// Expected output: true

Syntax

js
Atomics.isLockFree(size)

Parameters

size

The size in bytes to check.

Return value

Atrue orfalse value indicating whether the operation is lock free.

  • Alwaystrue ifsize is 4, because all known platforms support 4-byte atomic operations.
  • Alwaysfalse if the given size is not one of theBYTES_PER_ELEMENT property of integer TypedArray types.

Examples

Using isLockFree

js
Atomics.isLockFree(1); // true (platform-dependent)Atomics.isLockFree(2); // true (platform-dependent)Atomics.isLockFree(3); // falseAtomics.isLockFree(4); // trueAtomics.isLockFree(5); // falseAtomics.isLockFree(6); // falseAtomics.isLockFree(7); // falseAtomics.isLockFree(8); // true (platform-dependent)

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-atomics.islockfree

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp