Linux 线程(创建/等待/终止)
来源:互联网 发布:mysql 一天内的数据 编辑:程序博客网 时间:2024/05/16 01:47
http://blog.csdn.net/hubi0952/article/details/7982487
- /* FirstThreadFunc.c*/
- #include <stdio.h>
- //#include <unistd.h>
- //#include <stdlib.h>
- #include <pthread.h>
- void
- thread (void)
- {
- // sleep(1);
- int i;
- int tid = pthread_self();//返回自己的线程ID
- for (i = 0; i < 3; i++)
- printf ("This is a pthread\n");
- pthread_exit("hello world!!\n");//把字符串的首地址传给thread_result
- }
- int
- main (void)
- {
- void *thread_result;
- pthread_t id;
- int i, res;
- res = pthread_create(&id, NULL, (void *) thread, NULL);//创建线程
- pthread_join(id, &thread_result);//等待id的线程结束
- if(res != 0)
- {
- printf ("Create pthread error!\n");
- exit (1);
- }
- // sleep(1);
- for (i = 0; i < 3; i++)
- printf ("This is the main process\n");
- printf("thread joined ,it returned %s\n",(char *)thread_result);
- return (0);
- }
0 0
- Linux 线程(创建/等待/终止)
- Linux 线程(创建/等待/终止)
- linux线程(创建,等待,终止)
- Linux 线程(创建/等待/终止)
- Linux-线程(一)创建 终止 等待线程
- 线程创建、等待、终止
- 线程的创建、终止、等待
- 【Linux】线程(概念、特点、线程控制代码--创建/等待/终止、分离与结合属性)
- 【Linux】线程总结:初识、创建、等待、终止、分离
- Linux之线程的创建、等待、终止及分离
- 线程创建、线程等待、线程终止
- 线程的控制(创建、等待、终止)、分离线程
- 【linux】进程创建、等待、终止
- 线程的创建、终止、等待基本操作
- 线程的创建、等待与终止
- 线程的创建、等待及终止
- 线程的创建、等待、终止以及属性
- 线程的创建、等待、终止、分离
- jsp 学习(一)
- SpringMVC+ExtJS3.x实现文件上传
- Xcode设置项之Architectures和Valid Architectures
- Matlab7.1在win7 x64下无法运行的解决方法
- CPropertySheet里的帮助按钮如何去掉
- Linux 线程(创建/等待/终止)
- linux grep,最有用的搜索命令,中文版
- tomcat结合nginx使用小结
- 上海市人民政府办公厅转发市建设管理委关于在本市推进BIM技术应用指导意见
- 网页html分帧
- Java内存分配全面浅析
- java里面自动导包的快捷键
- bootstrap栅栏布局
- 附件地点搜索(非geohash)