C++标准线程库之共享资源

多线程下难免会需要资源共享,这样难免会发生异常情况。 #include <iostream> #include <thread> class X { int* _p; public: X(int* p = nullptr) : _p(p) {} ~X() { if(_p) delete _p; } void read() { if(_p
相关文章
相关标签/搜索