User Tools

Site Tools


c:c_threads:troubleshooting:program_crashes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c:c_threads:troubleshooting:program_crashes [2021/06/07 08:37] – created peterc:c_threads:troubleshooting:program_crashes [2021/06/09 11:10] (current) peter
Line 1: Line 1:
 ====== C - C++ Threads - Troubleshooting - Program Crashes ====== ====== C - C++ Threads - Troubleshooting - Program Crashes ======
  
-Forgetting to join a thread or detach it (make it unjoinable) before the main program terminates, will cause in program crash.+[[C:C++ Threads:Troubleshooting:Program Crashes:Forgetting to join a thread|Forgetting to join thread]]
  
-For example, the t1 thread is not joined to the main thread.+[[C:C++ Threads:Troubleshooting:Program Crashes:Trying to acquire a std::mutex twice|Trying to acquire a std::mutex twice]]
  
-<code bash> +[[C:C++ Threads:Troubleshooting:Program Crashes:Not handling exceptions in background threads|Not handling exceptions in background threads]]
-#include <iostream> +
-#include <thread> +
-using namespace std;+
  
  
-void HelloWorld() 
-{ 
-  cout << "Hello World" << endl; 
-} 
  
  
-int main() 
-{ 
-  thread t1(HelloWorld); 
-  //t1.join();  // If the thread is not joined to the main thread it will cause a crash. 
-  return 0; 
-} 
-</code> 
c/c_threads/troubleshooting/program_crashes.1623055030.txt.gz · Last modified: 2021/06/07 08:37 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki