Basically I need the Master thread to keep doing some operation based on the value of some global variables that can be edited (at some selected intervals) by a secondary thread. Something Like:
vector<int> mySharedVar;
void secondaryThreadFunction() {
   Do some operations
   And update mySharedVar if necessarily  
}
int main() {
 int count = 0;
 while(true) {
    count++;
    if (count%100) {  //> Each 100 iterations run a parallel thraed
      //> RUN secondaryThreadFunction in a separateThread
    }
    this is the main thread that based its operation on mySharedVar
 }
}
Which is the openmp command to run a single parallel thread with secondaryThreadFunction(); ?
Are there any other better way than this:
#pragma omp parallel num_threads(2)
    {
        int i = omp_get_thread_num();
        if (i == 0){
            mainThread();
        }
        if (i == 1 || omp_get_num_threads() != 2){
            secondaryThreadFunction();
        }
    }