C++实现线程安全的单例模式

使用饿汉式,在类外建立静态对象,main函数执行前已经建立完成。线程安全。(thread.cpp) 编译:g++ -pthread thread.cppios #include <pthread.h> #include <unistd.h> #include<iostream> using namespace std; class A { public: static A* getInstanc
相关文章
相关标签/搜索