1# Freezing a Sendable Object
2
3Sendable objects can be frozen. Frozen objects become read-only objects and cannot be added, deleted, or modified. Therefore, no lock is required for concurrent access between multiple instances. You can call the [Object.freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) API to freeze objects.
4
5## Samples
6
71. Provides the Object.freeze method encapsulated in TS files.
8
9   ```ts
10   // helper.ts
11   export function freezeObj(obj: any) {
12     Object.freeze(obj);
13   }
14   ```
15
162. Call the freeze method to freeze the object and send the object to the subthread.
17
18   ```ts
19   // Index.ets
20   import { freezeObj } from './helper';
21   import { worker } from '@kit.ArkTS';
22
23   @Sendable
24   export class GlobalConfig {
25       // Configuration attributes and methods.
26     init() {
27           // Initialize the logic.
28           freezeObj(this) // Freeze this object after the initialization is complete.
29     }
30   }
31
32   @Entry
33   @Component
34   struct Index {
35     build() {
36       Column() {
37         Text("Sendable freezeObj Test")
38           .id('HelloWorld')
39           .fontSize(50)
40           .fontWeight(FontWeight.Bold)
41           .onClick(() => {
42             let gConifg = new GlobalConfig();
43             gConifg.init();
44             const workerInstance = new worker.ThreadWorker('entry/ets/workers/Worker.ets', { name: "Worker1" });
45             workerInstance.postMessage(gConifg);
46           })
47       }
48       .height('100%')
49       .width('100%')
50     }
51   }
52   ```
53
543. Subthreads directly operate objects without locking them.
55
56   ```ts
57   // Worker.ets
58   import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS';
59   import { GlobalConfig } from '../pages/Index';
60
61   const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
62   workerPort.onmessage = (e: MessageEvents) => {
63     let gConfig: GlobalConfig = e.data;
64     // Use the gConfig object.
65   }
66   ```
67