Files
XCEngine/docs/api/threading/thread/start.md
ssdfasd 6a952473ce docs: fix threading module documentation discrepancies
- Fix include paths: use #include "Threading/..." instead of <XCEngine/Threading/...>
- Document protected ITask constructors (ITask(), ITask(TaskPriority))
- Document Callback typedef in TaskGroup
- Clarify Mutex STL-compatible methods are const
- Note GetProgress() implementation limitation (returns 0.0f)
2026-03-19 00:49:08 +08:00

38 lines
855 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::Start
```cpp
template<typename Func>
void Start(Func&& func, const Containers::String& name = "Thread")
```
启动线程,执行传入的可调用对象。该方法创建一个新的执行线程,立即开始运行。
**参数:**
- `func` - 要在线程中执行的可调用对象lambda、函数指针、仿函数等
- `name` - 线程名称,用于调试和日志输出,默认值为 "Thread"
**返回:**
**复杂度:** O(1)
**线程安全:** 该方法不是线程安全的,不应在同一 Thread 对象上并发调用。
**示例:**
```cpp
#include "Threading/Thread.h"
Thread worker;
worker.Start([]() {
printf("Worker thread running\n");
Thread::Sleep(100);
printf("Worker thread done\n");
}, "WorkerThread");
worker.Join();
```
## 相关文档
- [Thread 总览](thread.md) - 返回类总览