c:c_threads:join
Differences
This shows you the differences between two versions of the page.
c:c_threads:join [2021/03/05 02:05] – created peter | c: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: | ||
+ | |||
+ | Calling join on other threads in your __main__ application can cause the application to freeze. | ||
+ | |||
+ | A call to **std:: | ||
+ | |||
+ | * 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. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
[[C:C++ Threads: | [[C:C++ Threads: |
c/c_threads/join.1614909954.txt.gz · Last modified: 2021/03/05 02:05 by peter