I have got doubt, when I call ClassA:funcB()
from ClassA:funcA()
- where ClassA:funcA()
HAS monitor
and when I call ClassA:funcB()
it's inside monitor.
Here:
static pthread_mutex_t my_mutex;
ClassA::funcA()
{
monitor mp(my_mutex);
err = funcB();
}
ClassA::funcB()
{
...
stuff with NO lock etc
...
}
ClassA:funcB()
is getting called from ONLY funcA()
, is it thread safe?
Sure. If funcB
is only called from funcA
while funcA
has acquired the mutex, then you are thread safe.