Skip to content

Commit

Permalink
doc: Add threading in README
Browse files Browse the repository at this point in the history
  • Loading branch information
meloalright committed Oct 8, 2024
1 parent ae250cd commit 136a630
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,49 @@ $ 3body
// > true
```
##### Threading
```shell
程心(): Threading
```
`example:`
```rust
给 cx 以 程心();

给 星环公司 以 法则(name, y, limit) {
给 掩体纪年 以 y;
面壁 (掩体纪年 <= limit) {
冬眠(1000);
广播([name, 掩体纪年]);
掩体纪年 = 掩体纪年 + 1;
}
}

cx.thread(星环公司, ["掩体工程", 0, 11])
冬眠(5000)
cx.thread(星环公司, ["研制曲率飞船", 5, 11])
冬眠(6000)

// > ["掩体工程", 0]
// > ["掩体工程", 1]
// > ["掩体工程", 2]
// > ["掩体工程", 3]
// > ["掩体工程", 4]
// > ["研制曲率飞船", 5]
// > ["掩体工程", 5]
// > ["研制曲率飞船", 6]
// > ["掩体工程", 6]
// > ["研制曲率飞船", 7]
// > ["掩体工程", 7]
// > ["研制曲率飞船", 8]
// > ["掩体工程", 8]
// > ["研制曲率飞船", 9]
// > ["掩体工程", 9]
```
## Summary
|Token|3body-lang|Explanation|
Expand Down

0 comments on commit 136a630

Please sign in to comment.