• Home
Name Date Size #Lines LOC

..--

entry/12-May-2024-378298

screenshots/device/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-2024618 208

README_zh.mdD12-May-20241 KiB2814

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024174 21

package.jsonD12-May-2024376 1818

README.md

1# JsWorker
2
3
4
5### Introduction
6
7This sample shows how to start a worker thread in JS and implement the communication between the worker thread and host thread.
8
9### Usage
10
111. On the sample app, four strings are displayed on the home screen. After you touch **Sort string array**, these strings are sent to the worker thread. The worker thread sorts the strings and sends the result to the host thread. The host thread then displays the strings after sorting on the home screen.
12
132. You can touch **Clear** to clear the strings after sorting.
14
15
16
17### Constraints
18
19This sample can only be run on standard-system devices.
20

README_zh.md

1# 启动一个worker
2
3### 简介
4
5本示例展示了如何启动一个worker线程,并实现worker线程和宿主线程的通信。实现效果如下:
6
7![main](screenshots/device/main.png)
8
9### 相关概念
10
11Worker:Worker是与主线程并行的独立线程。创建Worker的线程称之为宿主线程,Worker自身的线程称之为Worker线程。创建Worker传入的url文件在Worker线程中执行,可以处理耗时操作但不可以直接操作UI。
12
13### 相关权限
14
15不涉及。
16
17### 使用说明
18
191.在首页中显示了排序前的四个字符串,点击**字符串排序**按钮,会将排序前的字符串发送给worker线程,在worker线程实现字符串排序,然后将排序后的字符串发送给主线程,主线程中显示排序后的字符串。
20
212.点击**清除**按钮,清除排序后的字符串。
22
23
24### 约束与限制
25
261.本示例仅支持标准系统上运行。
27
282.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。