Linux C++如何编写线程安全库?
看了当析构函数遇到多线程──C++ 中线程安全的对象回调这篇文章后,还是不太明白如何去做,是否有一些实际的例子可以学习一下?
PHP中文网2017-04-17 11:42:19
1 If a function can use local variables, try to use local variables. These variables allocated on the stack do not affect a function being called in different places.
2 If there is data shared by multiple functions, the most basic method is to lock the variables shared by multiple functions.
3 Consider using thread local storage