Skip to content

Commit 2b49c4a

Browse files
committed
article update
1 parent 4ca3f08 commit 2b49c4a

File tree

1 file changed

+21
-0
lines changed
  • docs/en/Community-Articles/2025-11-05-angular-multithreading

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Angular Multithreading: When to Use Web Workers vs Shared Workers
2+
3+
Modern web applications demand seamless user experiences, even when handling heavy computational tasks. Developers often face performance bottlenecks when heavy processing blocks the main thread, causing UI freezes and poor responsiveness.
4+
Web Workers and Shared Workers—two powerful browser APIs that enable true multithreading in web applications. While both move heavy computation off the main thread, they serve distinctly different purposes. This article explores when to use each type and provides practical implementation patterns in Angular.
5+
6+
### Understanding Main Thread Problem
7+
8+
The main thread is single-thread, meaning its handle only one task at a time. When heavy computation occurs on the main thread it blocks other critical tasks such as rendering and event handling. This leads to a poor user experience with UI freezes and unresponsiveness.
9+
10+
````typescript
11+
12+
// Example of blocking main thread
13+
function heavyComputation() {
14+
let sum = 0;
15+
for (let i = 0; i < 1e9; i++) {
16+
sum += i;
17+
}
18+
return sum;
19+
}
20+
console.log(heavyComputation()); // Blocks UI until done
21+
````

0 commit comments

Comments
 (0)