多核编程实验报1.docVIP

  • 8
  • 0
  • 约6.95千字
  • 约 12页
  • 2016-08-15 发布于贵州
  • 举报
实验 :Windows*Threads多线程编程 编译执行, 输出结果:(1) 简答与思考: 修改后的HelloThreads的代码 // HelloThreads.cpp : 定?§义°?控?制?台??§应?|用??程¨?序¨°的ì?入¨?口¨2点ì?。?ê #include stdafx.h #include windows.h const int numThreads = 4; DWORD WINAPI helloFunc(LPVOID pArg) { int j = *(int *)pArg; printf(Hello Thread %d\n,j); return 0; } int _tmain(int argc, _TCHAR* argv[]) { HANDLE hThread[numThreads]; int tNum[4]; for (int i = 0; i numThreads; i++) { tNum[i]=i; hThread[i] = CreateThread(NULL, 0, helloFunc, tNum[i], 0, NULL ); } WaitForMultipleObjects(numThreads, hThread, TRUE, INFINITE); return 0;

文档评论(0)

1亿VIP精品文档

相关文档