程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> #pragma omp threadprivate(alpha)

#pragma omp threadprivate(alpha)

編輯:關於C++
#include <omp.h>

int alpha[10],beta[10],i;
#pragma omp threadprivate(alpha)

main()
{
/* first parallel region */
#pragma omp parallel private(i,beta)
{   int id ;
    id = omp_get_thread_num();

    for(i=0;i<10;i++)
        alpha[i] = beta[i] = id * i;
}
/* second parallel region */
#pragma omp parallel
    printf("I am thread %d :alpha[3] = %d and beta[3] = %d\n", omp_get_thread_num(),alpha[3],beta[3]);

}
I am thread 0 :alpha[3] = 0 and beta[3] = 0
I am thread 3 :alpha[3] = 9 and beta[3] = 0
I am thread 2 :alpha[3] = 6 and beta[3] = 0
I am thread 1 :alpha[3] = 3 and beta[3] = 0
    No
  1. 下一頁:
Copyright © 程式師世界 All Rights Reserved