都知道java中有ThreadLocal变量,那么在C语言也是支持的,有两种方式来支持
第一种方法:
_thread int number; //通过gcc的关键字_thread
第二种方法:
pthread_key_create()、pthread_getspecific()、pthread_setspecific()、pthread_key_delete()
通过pthread库支持
都知道java中有ThreadLocal变量,那么在C语言也是支持的,有两种方式来支持
第一种方法:
_thread int number; //通过gcc的关键字_thread
第二种方法:
pthread_key_create()、pthread_getspecific()、pthread_setspecific()、pthread_key_delete()
通过pthread库支持