(from: http://topic.csdn.net/u/20090313/10/4c200070-3037-420b-983c-3329555f141d.html)
- Singleton* Singleton::instance()
- { if (!s_instance)
- { boost::mutex::unique_lock lock(your_mutex); //假设用boost的lock
- if(!s_instance) { //双判断
- s_instance = new Singleton;
- }
- }
- return s_instance;
- }
转载于:https://blog.51cto.com/wisenms/419838