结构
GLibThread
描述 [src]
struct GThread {
/* No available fields */
}
GThread 结构表示一个正在运行的线程。此结构由 g_thread_new() 或 g_thread_try_new() 返回。您可以通过调用 g_thread_self() 来获取表示当前线程的 GThread 结构。
GThread 具有引用计数,参见 g_thread_ref() 和 g_thread_unref()。它表示的线程在运行时持有引用,g_thread_join() 使用它给出的引用,所以通常不必显示管理 GThread 引用。
此结构为不透明结构——所有字段都不能直接访问。
构造函数
g_thread_new
此函数创建一个新线程。新线程通过使用参数 data 调用 func 来启动。此线程将一直运行到 func 返回或直到从新线程调用 g_thread_exit()。func 的返回值成为线程的返回值,此返回值可以用 g_thread_join() 获取。
since: 2.32
实例方法
g_thread_join
等待 thread 完成,即传递给 g_thread_new() 的函数 func 返回或调用了 g_thread_exit()。如果 thread 已终止,则 g_thread_join() 立即返回。