// bsp4a.cpp : main project file.
#include "stdafx.h"

#include <omp.h>



int _tmain(int argc, _TCHAR* argv[])
{
	const int MAX=10;
	int sum=0;
	int j;
/*
	int count = 0;
   #pragma omp parallel num_threads(MAX)
   {
	   #pragma omp atomic
         count++;
   }
   printf_s("Number of threads: %d\n", count);
*/

	sum=0;
	omp_set_num_threads(4);
	#pragma omp parallel for  private(sum)
		for (int i = 0; i < 10; ++i) {	
			printf("Summe: %d\n", sum );
     			sum=sum+1; 
		}
	printf("\r\nSumme: %d\n", sum );

	char ch[200];
	gets(ch);
	
	return 0;
}

// #pragma omp atomic
/*
#pragma omp critical
{
  sum=sum + i+1;  // i+1 oder 1
}
*/