线程回收
来源:互联网 发布:高淇java 编辑:程序博客网 时间:2024/06/09 23:45
主等子pthread_join ,pthread_exit
how to 回收 5 thread
thread_join can;t because it need 顺序
thread_detach how to retrieve ,pthread_exit(NULL)
#include <pthread.h>#include <stdio.h>#include <stdlib.h>int thread[5]={0};void *closeit(int k);void *m_cbf(void *__args);int main () {pthread_t m_threadId[5];int i;void *p;for (i=0;i<5;i++) {p=&i;// pthread_create(&m_threadId[i],NULL,m_cbf,(void *)i);pthread_create(&m_threadId[i],NULL,m_cbf,p);// printf("main thread m_threadId[%d]=%d\n",i,m_threadId[i]);}// pthread_join(); is block and must fix sequence to reback pthread_create// sleep(10);// for (i=0;i<5;i++) {// pthread_join(m_threadId[i],NULL);// printf("thread %d retrieve\n",i);// }// while (1 ) {// sleep (1);// }pthread_exit(NULL);printf("line61\n");return 0;}void *m_cbf(void *__args) {int k;void *q;q=__args;pthread_detach(pthread_self());// k=(int)__args;k=*(int *)q;// k=(int)*q;thread[k]=1;printf("thread %d\n",k);while (1) {closeit(k);}}void *closeit(int k) {pthread_t tid;tid=pthread_self();printf("close thread %d\n",k);// return NULL;pthread_exit(NULL) ;// exit ;}
0 0
- 线程回收
- java线程池线程回收
- linux线程回收
- linux线程资源回收
- 线程资源的回收
- 线程资源的回收
- 线程的终止与回收
- coding---进程、线程的回收
- linux线程资源回收方法
- linux线程资源回收方法
- linux线程资源回收方法
- linux线程资源回收方法
- 线程的停止与回收
- linux线程资源回收方法
- linux线程资源回收方法
- 线程退出和线程资源回收问题
- 线程的正常退出和资源回收
- Java线程是否会被垃圾回收
- 递归思想
- 黑马程序员_Java_泛型
- 初学Android,viewpager
- leetcode:Rotate Array旋转数组
- 数据结构学习网站
- 线程回收
- 【log】搭博记录
- 微信ibeacon使用场景步骤总结
- Google Play Alpha/beta testing.
- 递归实现字符串全排列
- 【转载】java 构造方法的继承
- C语言------数组和字符串
- 搜索引擎一:实现目标
- POJ 3613 Cow Relays (Floyd + 矩阵快速幂 + 离散化 神题!)