User Tools

Site Tools


c:c_threads:join

Differences

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

Link to this comparison view

c:c_threads:join [2021/03/05 02:05] – created peterc:c_threads:join [2021/03/05 02:09] (current) peter
Line 1: Line 1:
 ====== C - C++ Threads - join() ====== ====== C - C++ Threads - join() ======
  
 +<WRAP important>
 +**WARNING:**  std::thread::join() blocks the calling thread.
 +
 +Calling join on other threads in your __main__ application can cause the application to freeze. 
 +
 +A call to **std::thread::join()** blocks until the thread on which join is called, has finished executing.
 +
 +  * A join() in the main() will wait for the execution of the spawned threads to finish before it can exit the application.
 +  * If join() is not called after creating a thread the main function will not wait for the spawned thread to complete before it tears down the application. 
 +    * If the application tears down before the spawned thread finishes, it will terminate the spawned thread as well, even if it has not finished executing.
 +    * This can leave data in a very inconsistent state and should be avoided at all cost. 
 +
 +</WRAP>
 +
 +----
  
 [[C:C++ Threads:join()|join()]] [[C:C++ Threads:join()|join()]]
c/c_threads/join.1614909954.txt.gz · Last modified: 2021/03/05 02:05 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki