openharmony 鸿蒙 serializable-overview

2026-08-25 浏览 (1)

Overview of Inter-Thread Communication Objects

In multithreaded concurrency scenarios, such as creating background threads via TaskPool or Worker, data interaction between different threads is necessary. Due to memory isolation between threads, inter-thread communication objects must implement value copying or memory sharing through serialization.

NOTE

  • A maximum of 16 MB data can be serialized at a time.
  • Serialization does not support complex types decorated with decorators such as @State, @Prop, and @Link.

Currently, ArkTS supports the following types of objects for inter-thread communication:

  • Regular objects: ArkTS supports direct passing of basic data types and custom objects (which must comply with serialization specifications).
  • Container objects: ArkTS supports direct passing of container objects (which must comply with serialization specifications).
  • ArrayBuffer objects: used for efficient transmission of binary data, suitable for large segments of contiguous memory data (such as image or audio raw data).
  • SharedArrayBuffer objects: ArkTS supports shared memory across multiple threads, allowing direct access to the same memory area between threads, enhancing data transfer efficiency.
  • Transferable objects (NativeBinding objects): ArkTS supports transferring object ownership across threads (such as file descriptors and graphics resources), after which the original thread no longer has access rights.
  • Sendable objects: Objects that comply with the ArkTS language specification and can be shared, must be marked with the @Sendable decorator and meet Sendable constraints. For details, see Usage Rules and Constraints for Sendable.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 multi-thread-concurrency-overview

openharmony 鸿蒙 arkts-condition-variable-introduction

openharmony 鸿蒙 long-time-task-overview

openharmony 鸿蒙 batch-database-operations-guide

openharmony 鸿蒙 container-object

openharmony 鸿蒙 bytecode-obfuscation-guide

openharmony 鸿蒙 bytecode-obfuscation-questions

openharmony 鸿蒙 napi-define-sendable-object

openharmony 鸿蒙 arkts-lazy-import

openharmony 鸿蒙 independent-time-consuming-task

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/mkbjqSMc