1# SharedArrayBuffer Object
2
3SharedArrayBuffer contains a native memory block, which can be shared across concurrent instances. However, the Atomics class must be used for access and modification to prevent data competition. SharedArrayBuffer can be used for state sharing or data sharing between multiple concurrent instances. The following figure shows the communication process.
4
5![sharedarraybufer](figures/sharedarraybufer.png)
6
7
8## Samples
9
10The following is a simple example of using TaskPool to transfer an Int32Array object:
11
12```ts
13import { taskpool } from '@kit.ArkTS';
14
15@Concurrent
16function transferAtomics(arg1: Int32Array) {
17  console.info("wait begin::");
18  // Use Atomics to perform operations.
19  let res = Atomics.wait(arg1, 0, 0, 3000);
20  return res;
21}
22
23// Define an object that can be shared.
24let sab: SharedArrayBuffer = new SharedArrayBuffer(20);
25let int32 = new Int32Array(sab);
26let task: taskpool.Task = new taskpool.Task(transferAtomics, int32);
27taskpool.execute(task).then((res) => {
28  console.info("this res is: " + res);
29});
30setTimeout(() => {
31  Atomics.notify(int32, 0, 1);
32}, 1000);
33```
34