3, the handwriting strcpy, memcpy, memmove function;
2, thread synchronization in several ways:
Mutex, semaphore, critical section
1, to achieve a vector, it is 1.5 or 2 times? What advantages and disadvantages:
(1) 1.5-fold advantage: it can reuse the release of allocated memory before;
(2) double disadvantage: memory each application can not be reused;
0, thread-safe singleton
class Singleton{ private: static pthread_mutex_t mtx; static Singleton* instance; Singleton(){} ~Singleton(){} public: static Singleton* getInstance(){ if(instance == NULL){ pthread_mutex_lock(mtx); if(instance == NULL){ instance = new Singleton(); } pthread_mutex_unlock(mtx); } return instance; } }; pthread_mutex_t Singleton::mtx = PTHREAD_MUTEX_INITIALIZER; Singleton Singleton::instance = NULL;