windows下使用pthread

windows下使用pthread坑太多。ps:pc环境windows10,x64。编程

如下是在该环境下的配置和编程的注意事项:windows

一、把pthread的文件解压缩后,把Pre-built.2文件夹中的include和lib中的文件分别复制到VS安装目录…\Microsoft Visual Studio 10.0\VC\下的include和lib中。ui

 

二、#include <pthread.h>线程

#pragma comment(lib, "pthreadVC2.lib")io

 

三、64位系统:在VS工程属性->配置属性->连接器->输入->附加依赖项中添加“pthreads-w32-2-9-1-release\Pre-built.2\lib\x86\pthreadVC2.lib”。thread

 

四、64位系统:配置

应将pthreads-w32-2-9-1-release\Pre-built.2\dll\x86\ pthreadVC2.dll复制到C:\Windows\SysWOW64中.。im

 

五、建立线程:pthread_create(&sendCanMsgThread, NULL, SimulateSendCanMsg, NULL),同时建立多个线程,线程执行很快,须要延长执行时间才看获得交互执行。windows10

 

六、等待线程结束:pthread_join(sendCanMsgThread, NULL);di

相关文章
相关标签/搜索