国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
vs2010 使用pthread進(jìn)行多線程編程
vs2010 使用pthread進(jìn)行多線程編程
2014-06-23 15:53 1090人閱讀 評(píng)論(0)  舉報(bào)
 分類:
c/c++(11) 
1、從http://sourceware.org/pthreads-win32/下載pthread 的windows安裝包,我下的是pthread-w32-2-9-1-release.zip,其他版本也可以。解壓到pthread-w32-2-9-1-release。
2、打開vs2010,項(xiàng)目->屬性->配置屬性->VC++目錄,包含目錄里添加inlude路徑,如下圖所示,如果剛下載的壓縮包放在D盤,則在包含目錄那一欄添加:D:\pthread-w32-2-9-1-release\Pre-built.2\include;在庫目錄那一欄添加:D:\pthrea-w32-2-9-1-release\Pre-built2\lib
3、在鏈接器—>輸入,附加依賴項(xiàng)一欄添加
pthreadVC2.lib;pthreadVCE2.lib;pthreadVSE2.lib;如下圖所示。所有設(shè)置完成后點(diǎn)確定。
4、打開pthread-w32-2-9-1-release\Pre-built.2\lib\X86,將里面三個(gè)*.lib文件復(fù)制到你所建立的工程目錄中去,這樣就設(shè)置好了,大功告成。
如下一個(gè)簡(jiǎn)單的程序?qū)嵗?div style="height:15px;">
[cpp] view plain copy
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
#define NUM_THREADS 4
typedef struct{
int threadId;
}threadParm_t;
void *threadFunc(void *parm)
{
threadParm_t *p=(threadParm_t *)parm;
fprintf(stdout,"Hello world from thread%d\n",p->threadId);
pthread_exit((void *)&(p->threadId));
return 0;
}
int main(int argc,char *argv[])
{
int i;
int *res;
res=(int *)malloc(sizeof(int));
pthread_t thread[NUM_THREADS];
threadParm_t threadParm[NUM_THREADS];
for(i=0;i<NUM_THREADS;i++)
{
threadParm[i].threadId=i;
pthread_create(&thread[i],NULL,threadFunc,(void *)&threadParm[i]);
}
for(i=0;i<NUM_THREADS;i++)
{
pthread_join(thread[i],(void **)&res);
fprintf(stdout,"Thread %d has exited.\n",*res);
}
system("pause");
return 0;
}
運(yùn)行程序得到如下結(jié)果。
如果運(yùn)行時(shí),提示缺少“pthreadVC2.dll”,將pthread目錄下的pthreadVC2.dll文件拷貝到C:\Windows\System32(32位系統(tǒng))中即可
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
c語言多線程編程使用示例
iPhone開發(fā)多線程使用與注意事項(xiàng)
一個(gè) Linux 上分析死鎖的簡(jiǎn)單方法
線程局部存儲(chǔ)漫談 ? 搜索技術(shù)博客-淘寶
Linux 線程池
linux下C實(shí)現(xiàn)多線程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服