多核编程与并行计算实验报告 (1)(8)
发布时间:2021-06-07
发布时间:2021-06-07
多核编程与并行计算
}
void WithdrawThread2(LPVOID param)
{
}
int main(int argc , char * argv[])
{
}
evFin[0] = CreateEvent (NULL,FALSE,FALSE,NULL) ; evFin[1] = CreateEvent (NULL,FALSE,FALSE,NULL) ; InitializeCriticalSection(&cs) ; _beginthread(WithdrawThread1 , 0 , NULL) ; _beginthread(WithdrawThread2 , 0 , NULL) ; WaitForMultipleObjects(2 ,evFin ,TRUE ,INFINITE) ; DeleteCriticalSection(&cs) ; cout<<total<<endl; return 0 ; EnterCriticalSection(&cs) ; if ( total-20 >= 0) { } else cout<<"You do not have that much money"<<endl; LeaveCriticalSection(&cs) ; LeaveCriticalSection(&cs) ; SetEvent (evFin[1]) ; total -= 20 ; cout<<"You withdraw 20"<<endl; EnterCriticalSection(&cs) ; if ( total-90 >= 0) { } else cout<<"You do not have that much money"<<endl; LeaveCriticalSection(&cs) ; SetEvent (evFin[0]) ; total -= 90 ; cout<<"You withdraw 90"<<endl;