Atomics.wait(typedArray, index, value, timeout)
Parameters: This method accept four parameters as mentioned above and described below:
- typedarray: This parameter specifies a shared integer typed array Int16Array.
- index: This parameter specifies the position in the array, typedArray to wait on.
- value: This parameter specifies the expected value to test.
- timeout: This parameter is an optional parameter. It is time to wait in milliseconds.
Return value: The Atomics.wait() method returns the String which is either “ok”, “not-equal”, or “timed-out”.
Input: arr = 5 Atomics.wait(arr, 0, 0, 1) Output: not-equal Input: arr = 4 Atomics.wait(arr, 1, 0, 1) Output: time-out
5 5 not-equal 1
5 5 time-out 1
- If the typedArray is not a shared Int32Array then the Atomics.wait() operation throws a TypeError.
- If the index used as an argument to the Atomics.wait() operation is out of the bound in the typedArray then the Atomics.store( ) operation throws a RangeError.
- Google Chrome
- Microsoft Edge