创建一个线程默认的状态是joinable, 如果一个线程结束运行但没有被join,则它的状态类似于进程中的Zombie Process,即还有一部分资源没有被回收(退出状态码),所以创建线程者应该调用pthread_join来等待线程运行结束,并可得到线程的退出代码,回收其资源(类似于wait,.....
分类:
其他好文 时间:
2015-04-12 12:01:37
阅读次数:
125
头文件 : #include 函数定义: intpthread_join(pthread_t thread, void **retval);描述 :pthread_join()函数,以阻塞的方式等待thread指定的线程结束。当函数返回时,被等待线程的资源被收回。如果进程已经结束,那么该函数会立即返...
分类:
其他好文 时间:
2015-04-12 11:59:22
阅读次数:
187
1. 线程的等待退出 1.1. 等待线程退出 线程从入口点函数自然返回,或者主动调用pthread_exit()函数,都可以让线程正常终止 线程从入口点函数自然返回时,函数返回值可以被其它线程用pthread_join函数获取 pthread_join原型为: #include int pthrea...
分类:
编程语言 时间:
2015-04-11 17:42:59
阅读次数:
225
1. pthread_create(pthread类型指针变量 ,NULL ,函数 ,函数参数[多个参数用结构体传])2. pthread_join(pthread类型指针变量, 返回一般为null) pthread_join的作用: pthread_join()函数,以阻塞的方式等待threa.....
分类:
编程语言 时间:
2015-04-08 12:23:15
阅读次数:
151
http://www.360doc.com/content/13/0106/09/9171956_258497083.shtmlpthread_t pthr;pthread_create(&pthr, NULL, thread_handler, NULL);...void* thread_handl...
分类:
其他好文 时间:
2015-03-31 17:51:08
阅读次数:
145
http://www.cppblog.com/prayer/archive/2012/04/23/172427.html这两天在看Pthread 资料的时候,无意中看到这样一句话(man pthread_detach):Either pthread_join(3) or pthread_detach...
分类:
编程语言 时间:
2015-03-31 17:46:03
阅读次数:
186
apue第十一章、十二章详细介绍线程。关于线程的头文件:#include 关于线程的函数:pthread_self() , //获取自己的线程IDpthread_create(), //创建新线程,参数自己去翻pthread_exit(), //结束线程pthread_join(), ...
分类:
编程语言 时间:
2015-03-30 01:15:38
阅读次数:
172
Technorati 标签: Linux thread 索引: 1.创建线程pthread_create 2.等待线程结束pthread_join 3.分离线程pthread_detach 4.创建线程键pthread_key_create 5.删除线程键pthread_key_delete 6.设...
分类:
编程语言 时间:
2015-03-06 18:45:52
阅读次数:
209
官方说法:函数pthread_join用来等待一个线程的结束。函数原型为: extern int pthread_join __P ((pthread_t __th, void **__thread_return)); 第一个參数为被等待的线程标识符,第二个參数为一个用户定义的指针,它能够用来存.....
分类:
其他好文 时间:
2015-01-27 23:10:18
阅读次数:
174
thread.c程序pthread_create函数第三个参数为线程函数的起始地址,文中并无add函数,源代码如下:thread.c编译时会报未声明错误:根据语境推测应该是count,替换如下:重新编译,gcc编译时在最后加参数-lpthread,否则编译报对pthread_create和pthread_join未定义的引用如下:..
分类:
编程语言 时间:
2014-12-25 06:46:59
阅读次数:
215