- 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)
855 B
855 B
Thread::Start
template<typename Func>
void Start(Func&& func, const Containers::String& name = "Thread")
启动线程,执行传入的可调用对象。该方法创建一个新的执行线程,立即开始运行。
参数:
func- 要在线程中执行的可调用对象(lambda、函数指针、仿函数等)name- 线程名称,用于调试和日志输出,默认值为 "Thread"
返回: 无
复杂度: O(1)
线程安全: 该方法不是线程安全的,不应在同一 Thread 对象上并发调用。
示例:
#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 总览 - 返回类总览