#include <iostream>
#include <chrono>
#include <omp.h>
#include <math.h>

int main()
{
	std::cout << "\nOMP: \n";
	int j = 0;
	double start_time = omp_get_wtime();//start time

	//Share the workload
	#pragma omp parallel for num_threads(100) shared(j)
	for (int i = 0; i < 100000; ++i) 
	{
		// #pragma omp critical
		std::cout << "I am thread " << omp_get_thread_num() << " and I have received index " << i << " the value of j is: " << j << std::endl;
		// #pragma omp atomic
		// #pragma omp critical
		j++;
	}

	std::cout << j << std::endl;
	double end_time = omp_get_wtime();//end time
	std::cout << "\nSeconds: " << end_time - start_time; //total time
}