Linux pthread 入门
2017-02-15 15:58
363 查看
后续持续更新~~~~
2017-02-15
1.初次在Linux平台上使用pthread,写了一个小例子进行测试
实例程序如下:
编译:gcc pthread.c -o test -lpthread(注意:一定要添加-lpthread,作为附加依赖库)
2.把main函数中,函数的实体进行循环,加上for(int i=0; i<3; i++)进行循环三次
编译:gcc -std=gnu99 pthread.c -o test -lpthread 或者为gcc -std=c99 pthread.c -o test -lpthread
3.看了一个有些看不懂的博客,可能后续用得到,讲的是pthread线程的属性为可结合和分离的区别
http://bbs.51cto.com/thread-1075078-1.html
2017-02-15
1.初次在Linux平台上使用pthread,写了一个小例子进行测试
实例程序如下:
#include <pthread.h> #include <stdio.h> #include <stdlib.h> pthread_cond_t condition_cond = PTHREAD_COND_INITIALIZER; void *test() { printf("111\n"); } int main() { pthread_t ntid; int err; int flag = 1; err = pthread_create(&ntid,NULL,test,NULL); if(err!=0) { printf("create thread error\n"); exit(0); } pthread_join(ntid,NULL); return 0; }
编译:gcc pthread.c -o test -lpthread(注意:一定要添加-lpthread,作为附加依赖库)
2.把main函数中,函数的实体进行循环,加上for(int i=0; i<3; i++)进行循环三次
编译:gcc -std=gnu99 pthread.c -o test -lpthread 或者为gcc -std=c99 pthread.c -o test -lpthread
3.看了一个有些看不懂的博客,可能后续用得到,讲的是pthread线程的属性为可结合和分离的区别
http://bbs.51cto.com/thread-1075078-1.html
相关文章推荐
- Linux ARM交叉编译工具链制作过程
- linux系统ip配置笔记
- linux常用命令——3.文件打包压缩
- Linux IO模式及 select、poll、epoll详解
- Centos7完美重置root密码(极简步骤,附图)
- linux Tar 命令参数详解
- centos systemTap安装教程和如何为其他机器生成测量工具
- centos 7 升级/安装 git 2.7.3
- linux设置系统变量
- hadoop下linux集群间设置ssh免密登录
- Centos6.5配置阿里云yum源
- CentOS 6.5安装MySQL 5.6.10
- 鸟哥的Linux私房菜10.16 vim程序编辑器
- 鸟哥的Linux私房菜10.15 档案与文件系统的压缩与打包
- 鸟哥的Linux私房菜10.14 磁盘与文件系统管理
- 鸟哥的Linux私房菜10.13 档案与目录管理
- Linux命令--其他文件搜索命令
- linux环境下RabbitMQ-3.6.6安装
- 鸟哥的Linux私房菜10.12 档案权限与目录配置(root身份)
- Linux下往github上传项目