NAME
g_thread_init - 初始化線程系統
SYNOPSIS
#include <glib.h> //in gthread.h
void g_thread_init (GThreadFunctions *vtable);
Date Structure

typedef struct _GThreadFunctions GThreadFunctions; struct _GThreadFunctions { GMutex* (*mutex_new) (void); void (*mutex_lock) (GMutex *mutex); gboolean (*mutex_trylock) (GMutex *mutex); void (*mutex_unlock) (GMutex *mutex); void (*mutex_free) (GMutex *mutex); GCond* (*cond_new) (void); void (*cond_signal) (GCond *cond); void (*cond_broadcast) (GCond *cond); void (*cond_wait) (GCond *cond, GMutex *mutex); gboolean (*cond_timed_wait) (GCond *cond, GMutex *mutex, GTimeVal *end_time); void (*cond_free) (GCond *cond); GPrivate* (*private_new) (GDestroyNotify destructor); gpointer (*private_get) (GPrivate *private_key); void (*private_set) (GPrivate *private_key, gpointer data); void (*thread_create) (GThreadFunc func, gpointer data, gulong stack_size, gboolean joinable, gboolean bound, GThreadPriority priority, gpointer thread, GError **error); void (*thread_yield) (void); void (*thread_join) (gpointer thread); void (*thread_exit) (void); void (*thread_set_priority)(gpointer thread, GThreadPriority priority); void (*thread_self) (gpointer thread); gboolean (*thread_equal) (gpointer thread1, gpointer thread2); };
DESCRIPTION
如果你在多個線程中使用Glib,那么你必須調用這個函數來初始化線程系統.
該函數不可以在Glib的CallBack中直接或間接被調用,Also no mutexes may be currently locked while calling g_thread_init()。
使用該函數必須連接gthread庫,`pkg-config --libs gthread-2.0`
從v2.24版本開始,允許多次調用該函數,但是只有第一次調用有效,其他調用無效。
從v2.32版本開始,Glib不再支持自定義線程實現,vtable 參數會被忽略,所以參數 vtable 應該設置為NULL;
從v2.32版本開始,該函數已被棄用,因為Glib系統會在程序開始前自動完成線程系統初始化。
PARAMETERS
①vtable
GThreadFunctions類型的函數table, v2.32版本后應該設置為NULL