0
當我執行shell輸出下面的代碼可能線程0和線程之間的重疊1. 所以我想問你的是,以確保每個線程完成輸出寫作的最好方式在另一個開始輸出之前?如何IO使用OpenMP部分同步
這將確保在輸出中是乾淨的。
非常感謝提前!
#pragma omp parallel num_threads(2) shared(emperor)
{
#pragma omp sections
{
#pragma omp section
{
cout << "Open the listening thread by using openmp!" << endl;
emperor->startServerListening(); /// does some work
}
#pragma omp section
{
cout << "Open the master thread by using openmp!" << endl;
emperor->startServerCoupling(); /// does some other work
}
} /// End of sections
} /// End of parallel section