简单linux线程示例代码
2015-11-14 13:36
344 查看
1、操作系统版本为Ubuntu 15.10。
2、代码参考链接点击打开链接
3、需要改动其中的头文件,删除#include <sys/time.h>这个头文件。
4、在其中用到了sleep()这个函数,需要引用头文件#include <unistd.h>。(这个头文件在不同的gcc编译环境下不同)
5、在其中用到了memset()这个函数,引用头文件#include <string.h>.
6、由于使用pthread_create、pthread_join等函数,除了引用头文件#include <pthread.h>外,在编译时需要使用下面命令:
gcc -c test.c
gcc -o test test.o -lpthread
才能正常编译成可执行文件。
具体原因参考:点击打开链接
2、代码参考链接点击打开链接
3、需要改动其中的头文件,删除#include <sys/time.h>这个头文件。
4、在其中用到了sleep()这个函数,需要引用头文件#include <unistd.h>。(这个头文件在不同的gcc编译环境下不同)
5、在其中用到了memset()这个函数,引用头文件#include <string.h>.
6、由于使用pthread_create、pthread_join等函数,除了引用头文件#include <pthread.h>外,在编译时需要使用下面命令:
gcc -c test.c
gcc -o test test.o -lpthread
才能正常编译成可执行文件。
具体原因参考:点击打开链接
相关文章推荐
- linux 修改 机器名 root@localhost
- Linux - GIT
- Linux开启ftp服务
- Linux - SSH
- Linux diff命令
- linux的测试题
- Linux 设置新创建目录或文件的默认权限
- Hadoop完全分布式集群搭建手记(CentOS6.7+Hadoop2.6手把手胸贴胸详细版)
- java开发需要知道的一些linux命令
- linux服务器访问windows共享文件
- Linux 搭建vsftpd服务器-实战操作
- 浏览器linux终端交互工具--tty.js
- selenium API和使用(二)
- selinium API和使用(一)
- linux进程通信-有名管道
- Linux 下Ftp的搭建
- linux进程间的通信-无名管道
- linux下 火狐浏览器 默认语言更改为中文
- Linux挂载U盘-实战操作
- linux下ifconfig,service等命令不能直接使用