Windows下使用pthread
来源:互联网 发布:java前后端分离session 编辑:程序博客网 时间:2024/05/18 00:25
1.下载pthreads-w32-2-8-0-release.exe
下载地址:ftp://sourceware.org/pub/pthreads-win32
2. 安装pthreads-w32-2-8-0-release.exe
双击pthreads-w32-2-8-0-release.exe,点击Browse选择安装到的目录,然后点击Extract解压,完成后点击Done。
之后会在安装目录看到有三个文件夹Pre-built.2、pthreads.2、QueueUserAPCEx.
第一个是生成库(头文件和库文件那些),第二个是源码,第三个不清楚,像是测试程序。
将Pre-built.2文件夹下的include和lib文件夹里的文件复制到VS2008对应的include和lib目录,我这里是C:\Program Files\Microsoft Visual Studio 9.0\VC\include和C:\Program Files\Microsoft VisualStudio 9.0\VC\lib.
3. 编写测试程序
- #include<stdio.h>
- #include<pthread.h>
- #include<Windows.h>
- #pragma comment(lib, "pthreadVC2.lib") //必须加上这句
- void*Function_t(void* Param)
- {
- pthread_t myid = pthread_self();
- while(1)
- {
- printf("线程ID=%d \n", myid);
- Sleep(4000);
- }
- return NULL;
- }
- int main()
- {
- pthread_t pid;
- pthread_create(&pid, NULL, Function_t,NULL);
- while (1)
- {
- printf("in fatherprocess!\n");
- Sleep(2000);
- }
- getchar();
- return 1;
- }
和Linux的pthread一样~直接编译运行就ok了。如果运行提示缺少pthreadVC2.dll,就将Pre-built.2\lib目录下的pthreadVC2.dll拷贝到可执行文件所在目录就行了。
0 0
- Windows下使用pthread
- Windows下使用pthread
- windows 下使用 pthread
- Windows下使用pthread
- Windows下使用pthread
- windows 下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- windows下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- windows下使用pthread库
- windows下使用pthread库
- windows下使用pthread库
- Windows+VS2008 下使用pthread
- WINDOWS下使用PTHREAD库
- windows下使用pthread库
- foj 1303
- AndroidSDK和ADT下载地址
- Android 中switch case 报错 R.id.xxx没有final
- 关于SharePrefenerces的使用
- 归并排序算法
- Windows下使用pthread
- 《C语言及程序设计》实践参考——让吃货失望的菜单
- UVA - 10229 - Modular Fibonacci (矩阵快速幂 + fibonacci)
- 网络编程步骤 乔老师整理
- 如何利用你的【坏习惯】学习?
- postive psychology
- hdoj.4503 湫湫系列故事——植树节【排列组合】 2015/04/30
- WCF系列_分布式事务(上)
- 我的CSDN博客开通啦!