Synchronization is a fundamentally difficult problem that raises issues that simply do not arise in ordinary sequential programs.
Thread safety issues:
1.Functions that do not protect shared variables.
2.Functions that keep state across multiple invocations.
3.Functions that return a pointer to a static variable
4. Functions that call thread-unsafe functions.
Reentrancy issues:
![](https://img-my.csdn.net/uploads/201301/01/1357024482_6625.png)
Reentrancy functions are typically more efficient than nonreentrant thread-safe functions because they no synchronization operations.
If all function arguments are passed by value and all data references are to local automatic stack variable,then the function is explicitly reentrant.
If we loosen our assumptions a bit and allow same parameters in our otherwise explicitly reentrant function to be passed by reference then we have an implicitly reentrant function.
It's important to realize that reentrancy is sometimes a property of both the caller and the callee, and not just the callee alone.