Files
XCSDD/docs/api/threading/thread/start.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

855 B
Raw Permalink Blame History

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();

相关文档