I have an array pointers.
Can I use mutex for lock and unlock? At the same time, Another thread run with the same and check matrix[h].
int **matrix;
matrix =new int[20];
for(int i=0; i<20; i++)
{
matrix[i]= new int[20];
}
#pragma omp parallel for nowait
for(int h=0; h< 20; ++h)
{
if(matrix[h].isfree()==true)
{
lock(matrix[h]);
//do something...
unlock(matrix[h]);
}
else
{
//that array matrix[h] is not free.
skip++;
}
}