1# SharedArrayBuffer Object 2 3A SharedArrayBuffer object contains a block of native memory, and its JS object wrapper is allocated in the local heap of the virtual machine. It allows sharing native memory across concurrent instances but requires the use of the Atomics class to access and modify the shared native memory, thereby preventing data races. It is suitable for sharing state or data among multiple concurrent instances. The following figure shows the communication process. 4 5 6 7 8## Usage Example 9 10The following is an example of using TaskPool to pass 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<!-- @[example_pass_obj](https://gitee.com/openharmony/applications_app_samples/blob/master/code/DocsSample/ArkTs/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/CommunicationObjects/entry/src/main/ets/managers/SharedArrayBufferObject.ets) --> 35 36<!--no_check-->