harmony 鸿蒙Concurrency Overview
Concurrency Overview
Concurrency refers to the capability of processing multiple tasks in the same period. To improve the response speed and frame rate of applications and prevent time-consuming tasks from blocking the main thread, OpenHarmony provides two policies: asynchronous concurrency and multithread concurrency.
Asynchronous concurrency means that an action in asynchronous code is suspended and will continue later. Only one segment of code is being executed at a time.
Multithread concurrency allows multiple segments of code to be executed at a time. When the main thread continues to respond to user operations and update the UI, time-consuming operations are performed in the background to avoid application freezing.
Concurrency is used in a variety of scenarios, including a single I/O task, CPU intensive task, I/O intensive task, synchronous task, and the like. You can select a concurrency policy based on your scenario.
ArkTS provides the following mechanisms to support asynchronous concurrency and multithread concurrency:
Promise and async/await: provide asynchronous concurrency and apply to the development of a single I/O task. For details, see Asynchronous Concurrency Overview.
TaskPool and Worker: provide multithread concurrency and apply to the development of CPU intensive tasks, I/O intensive tasks, and synchronous tasks. For details, see Multithread Concurrency Overview.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙ArkTS Common Library
harmony 鸿蒙Comparison Between the Actor and Memory Sharing Models
harmony 鸿蒙Overview of ArkTS Common Library
harmony 鸿蒙Asynchronous Concurrency Overview
harmony 鸿蒙Overview of Containers
harmony 鸿蒙CPU Intensive Task Development
harmony 鸿蒙I/O Intensive Task Development
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦