Introduction to SharedArrayBuffer

The SharedArrayBuffer is the way to create a memory store which is accessible to all workers simultaneously. Now, if you've been reading keenly, you will have understood something mischievous that can happen once something like a shared memory store is allowed to exist.

If you remember, the only reason workers didn't have direct access to DOM was because the DOM API is not thread-safe, and could cause problems like deadlocks and race conditions. And if you were able to judge that the same thing might happen here, you're right! But that's a topic for a later section (The race condition).

Let's get back to SharedArrayBuffer. So what's different from ArrayBuffer?

Well, SharedArrayBuffer is pretty much the

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.