fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
38
docs/api/threading/thread/detach.md
Normal file
38
docs/api/threading/thread/detach.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Thread::Detach
|
||||
|
||||
```cpp
|
||||
void Detach()
|
||||
```
|
||||
|
||||
分离线程,使其成为后台线程独立运行。分离后,线程的资源将在其终止时自动释放,调用线程不会被阻塞。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**注意:**
|
||||
- 分离后的线程无法再被 Join 或进行任何同步操作。
|
||||
- 确保分离线程的所有资源访问都是线程安全的,因为主线程可能在分离线程结束前退出。
|
||||
- 如果 Thread 对象在分离线程结束前被销毁,行为取决于具体实现。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Thread background;
|
||||
background.Start([]() {
|
||||
printf("Background task running\n");
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
Thread::Sleep(500);
|
||||
printf("Background: tick %d\n", i);
|
||||
}
|
||||
}, "BackgroundThread");
|
||||
|
||||
background.Detach();
|
||||
printf("Main thread continues immediately\n");
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Thread 总览](thread.md) - 返回类总览
|
||||
Reference in New Issue
Block a user