views:

53

answers:

1

Hi

I am considering using OpenMP for multithreading in C++. But I wonder if there is a way tell a thread not to wait for other concurrent thread and continue with my program? (Maybe I can cancel/kill other threads?)

I am aware of the existence of "nowait" clause, but I want the decision of "wait" or "not to wait" to be done dynamically (The program will decide depending on results of the process I am doing).

I hope I can get some advices on this.

Thanks in advance.

+1  A: 

I'd would do it something along the lines of

if(conditon)
{
     taskA_with_Barriers();
}  
else
{
     taskA_without_Barrier();
}

The condtion needs to be the same constant through out all threads.

If you need to be canceling Threads you might be using the wrong technolgy. Might also want to take a look at pthreads or MPI.

mikek3332002
@nacho4d if you are using C++, it makes more sense to use boost threads. OpenMP maybe very limiting in what you can do
aaa