hThread1=CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) ThreadFunc1, NULL, 0, & amp; ThreadID1);
The CloseHandle (hThread1);
HThread2=CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) ThreadFunc2, NULL, 0, & amp; ThreadID2);
The CloseHandle (hThread2);
HThread3=CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) ThreadFunc3, NULL, 0, & amp; ThreadID3);
The CloseHandle (hThread3);
Double a=0;
A + a=(A1, A2 and A3)/4.
A main thread, Thread1 for A1, A2 Thread2, Thread3 A3,
Performed for the first time, only A/A1 has value, A2/A3, the return value is 0,
The second executes, normal,
CodePudding user response:
Check the function return valuehttps://msdn.microsoft.com/en-us/library/ms682453 (vs. 85). Aspx
CodePudding user response:
You should wait for all threads are finished calculation to calculate a=(a + A1, A2 and A3)/4.CodePudding user response:
You is to create threads, thread has not completed calculation, have to wait after the thread execution, to the calculation results,Is generally do this: after the thread to send a message to the main thread, the main thread after receiving the message, to calculate again,
CodePudding user response:
"Windows core programming"