多线程

 1 #include <stdio.h>
 2 #include <pthread.h>
 3 
 4 void* say_hello(void* args) {
 5     printf("hello from thread!\n");
 6     pthread_exit((void*)1);
 7     return (void*) 1;
 8 }
 9 int main() {
10     pthread_t tid;
11     int iRet = pthread_create(&tid,NULL,say_hello,NULL);
12     if (iRet) {
13         printf("creat error:iRet = %d\n", iRet);
14         return iRet;
15     }
16     void *retval;
17     iRet = pthread_join(tid, &retval);
18     if (iRet) {
19         printf("join error: iRet = %d\n", iRet);
20         return iRet;
21     }
22     printf("retval = %d\n", (long)retval);
23     return 0;
24 }

 

上一篇:条件变量与互斥量(2)


下一篇:torch.nn.Unfold()详细解释