A.26 threadprivate 지시문 사용
다음 예제를 사용 하는 방법을 보여는 threadprivate 지시문 (섹션 2.7.1 페이지 23) 각 스레드가 별도 카운터를 제공 합니다.
예제 1:
int counter = 0;
#pragma omp threadprivate(counter)
int sub()
{
counter++;
return(counter);
}
예제 2:
int sub()
{
static int counter = 0;
#pragma omp threadprivate(counter)
counter++;
return(counter);
}