Namespaces
Variants

std::thread:: ~thread

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
~thread ( ) ;
(C++11 이후)

스레드 객체를 파괴합니다.

만약 * this 가 연결된 스레드를 가지고 있다면 ( joinable ( ) == true ), std:: terminate ( ) 가 호출됩니다.

참고 사항

스레드 객체는 다음과 같은 경우에 연관된 스레드를 갖지 않으며(파괴해도 안전함):

  • 기본 생성되었을 때
  • 이동되었을 때
  • join() 가 호출되었을 때
  • detach() 가 호출되었을 때

예제

#include <thread>
using namespace std::chrono_literals;
int main()
{
    auto bleah = std::thread{[]{ std::this_thread::sleep_for(13ms); }};
}   // ~thread calls std::terminate()

가능한 출력:

terminate called without an active exception

참고 항목

스레드가 조인 가능한 상태라면, 중단 요청을 하고 스레드를 조인합니다
( std::jthread 의 public member function)