1. Multi-threaded access to shared resources is not locked
Error Tip: Segmentation fault!
Workaround:
 
 
  
  - Multi-threaded read no need to lock
  
  - Multi-threaded simultaneous read and write requires lock
The method of locking is the event notification mechanism provided by the combination of mutex, semaphore, read-write lock, record lock, mutex and condition variable.
C++11, Lock_guard,unique_lock. Both are locked at the time of construction, and when the destruction is locked. But Unique_lock provides more features, such as the ability to specify that it is not locked at construction time, and then called when needed. Lock () lock. If combined with condition_variable, use only unqiue_lock.  
 
 
2. The pointer variable is not initialized to nullptr at the time of definition, or at some point execution becomes a dangling pointer, causing unpredictable errors.
Error tip: Segmentaion fault!
Workaround:
 
 
  
  - Pointer variables are initialized to nullptr at the time of declaration, and when used to determine if (!PTR)
  
  - Check the code carefully to avoid hanging hands.
  
 
 
3. Std::thread in joinalble state causes terminate
Error message: Terminate called without an active exception. Aborted
Workaround:
 
 
  
  - Call detach to detach thread when creating thread
  
  - Call join after thread executes to wait for thread to end normally
However, after writing a lot of code, sometimes in a code branch prematurely exit and cause thread destruction without running to the join statement, which will lead to terminate;
The sample code is as follows:  
 
 
 
 
 
 void foo()  
 
 {  
 
 //do something;  
 
 }  
 
   
 
 int main()  
 
 {  
 
  std::thread t(foo);  
 
 if(true)return1;  
 
  t.join();  
 
 return0;  
 
 }  
Code 8 o'clock T constructs and runs with Foo, this is for the joinable state, the Code 9 o'clock program exits, causing T to be refactored before T.join (), and thread will cause terminate under joinable state destruction. The ~thread function is described in Cplusplus as follows:
If the thread is joinable -Destroyed, terminate () is called.
From for notes (Wiz)
 Program crashes debug logging and summary