Files
XCSDD/docs/api/threading/thread/join.md
ssdfasd 58a83f445a 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
2026-03-19 12:44:08 +08:00

38 lines
760 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Thread::Join
```cpp
void Join()
```
等待线程结束并回收其资源。调用线程将被阻塞,直到目标线程完成执行。
**参数:**
**返回:**
**复杂度:** O(n)n 为目标线程的执行时间
**注意:**
- 如果线程已经被分离Detach或已经 Join 过,调用此方法将导致未定义行为。
- 建议在使用完 Thread 对象后始终调用 Join 或 Detach。
**示例:**
```cpp
Thread worker;
worker.Start([]() {
for (int i = 0; i < 5; ++i) {
printf("Working...\n");
Thread::Sleep(100);
}
}, "WorkerThread");
printf("Main thread waiting...\n");
worker.Join();
printf("Worker thread finished\n");
```
## 相关文档
- [Thread 总览](thread.md) - 返回类总览