Skip to content

Commit 9ef303d

Browse files
committed
doc: update multiple thread mode.
1 parent f2137d1 commit 9ef303d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
277 KB
Loading

website/docs/tutorials/performance_optimization/multiple_thread_mode.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,22 @@ WebFController controller2 = WebFController(
5656
runningThread: group.slave(),
5757
devToolsService: ChromeDevToolsService(),
5858
);
59-
```
59+
```
60+
61+
## How to Choose Between Dedicated-Threading or Single-Threading Mode
62+
63+
Different threading modes offer various advantages depending on the scenario.
64+
65+
It's difficult to categorize threading models simply as good or bad. In this section, we will explore the applicable scenarios for different threading modes and how to choose between them.
66+
67+
![img](./imgs/thread_mode_diff.png)
68+
69+
The advantage of single-thread mode is the efficient communication cost between the JavaScript runtime and the Flutter UI, especially if your apps contain a lot of JavaScript-controlled animations.
70+
71+
However, the disadvantage of single-thread mode is still obvious—any execution of JavaScript will block the running of Dart, affecting animations and gesture handling.
72+
73+
If your application does not require significant JavaScript runtime and it does not noticeably affect the running of the Flutter UI, using single-thread mode is a good choice. Additionally, it helps reduce delays in JavaScript animation states relative to the actual UI results.
74+
75+
On the other hand, dedicated-threading mode is the counterpart of single-threading mode, where JavaScript execution won't block Dart execution unless necessary. However, the downside is the increased time for cross-thread synchronization.
76+
77+
But in most scenarios, especially for Vue or React users, using dedicated-threading mode is a preferred choice most of the time.

0 commit comments

Comments
 (0)