When a thread object goes out of scope and it is in joinable state, the program is terminated. The Standard Committee had two other options for the destructor of a joinable thread. It could quietly join — but join might never return if the thread is stuck. Or it could detach the thread (a detached thread is not joinable). However, detached threads are very tricky, since they might survive till the end of the program and mess up the release of resources. So if you don’t want to terminate your program, make sure you join (or detach) every thread.
Related Posts:
- What exactly is std::atomic?
- Thread pooling in C++11
- What is a lambda expression in C++11?
- ld: symbol(s) not found for architecture x86_64 error
- What is the ‘override’ keyword in C++ used for? [duplicate]
- Mutex example / tutorial? [closed]
- What is a smart pointer and when should I use one?
- Meaning of = delete after function declaration
- C++ std::priority_queue uses the lambda expression
- Usage and Syntax of std::function
- What exactly is nullptr?
- Difference between `constexpr` and `const`
- Split a string using C++11
- How to create timer events using C++ 11?
- What does T&& (double ampersand) mean in C++11?
- Segmentation fault error 11 C++
- Why doesn’t C++ have a garbage collector?
- Compiling C++11 with g++
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- terminate called after throwing an instance of ‘std::out_of_range’
- Cleanest way to copy a constant size array in c++11
- push_back vs emplace_back
- undefined reference to ‘std::cout’
- What is move semantics?
- expression preceding parentheses of apparent call must have (pointer-to-) function type
- C++ error: Undefined symbols for architecture x86_64
- How does std::forward work? [duplicate]
- Difference in make_shared and normal shared_ptr in C++
- What is std::move(), and when should it be used?
- C++: std does not have member “string”
- push_back vs emplace_back
- error: use of deleted function
- pthread sleep linux
- Call to implicitly deleted copy constructor in LLVM
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- no match for ‘operator<<’ in ‘std::operator
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- Use the auto keyword in C++ STL
- Call to non-static member function without an object argument compiler error
- Does C++11 have C#-style properties?
- Iterator Loop vs index loop
- initialize a vector to zeros C++/C++11
- When is it safe to call this-> in constructor and destructor
- How to memset char array with null terminating character?
- OpenMP set_num_threads() is not working
- How well is Unicode supported in C++11?
- How to automatically convert strongly typed enum into int?
- Why should I use a pointer rather than the object itself?
- too many initializers for ‘int [0]’ c++
- overloaded function with no contextual type information
- Creating folders in C++
- convert string to size_t
- Compiling C++11 with g++
- ERROR C2039: ‘vector’: is not a member of ‘std’
- Does static constexpr variable inside a function make sense?
- c++ vector bubble sort
- How to use bitmask?
- Differences between unique_ptr and shared_ptr
- How to create a dynamic array of integers
- How to implement 2D vector array?
- What is the difference between g++ and gcc?
- What is the best way to use a HashMap in C++?
- What is the difference between “long”, “long long”, “long int”, and “long long int” in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- How do I convert a double into a string in C++?
- How to concatenate two strings in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- Read file line by line using ifstream in C++
- Virtual/pure virtual explained
- ‘cout’ was not declared in this scope
- How does ifstream’s eof() work?
- How to iterate through a list of objects in C++?
- Examples of good gotos in C or C++
- Sleep function in C++
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- Division in C++
- splitting a string into an array in C++ without using vector
- Remove spaces from std::string in C++
- How to use glOrtho() in OpenGL?
- error: ‘ostream’ does not name a type
- Remove spaces from std::string in C++
- Read data from a file into an array – C++
- Unknown override specifier, missing type specifier
- error: overloaded ‘operator<<' must be a binary operator (has 3 parameters)
- prototype for “….” does not match any in class “…”
- Cannot open Windows.h in Microsoft Visual Studio
- Nested For – Loops to create multiplication table C++
- Reading and writing binary file
- GCC -fPIC option
- Xcode 11.1: iostream’ file not found
- non-member function cannot have cv-qualifier
- function does not take 1 arguments c++
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- What is the difference among ios::app, out, and trunc in c++?
- Where can I find ‘winmm.lib’ (I’m using Visual Studio 2012)
- What is a `char*`?
- “Incomplete type not allowed ” when creating std::ofstream objects