때로는 std::thread응용 프로그램 속도를 높이기 위해 사용해야 합니다. 또한 join()스레드가 완료 될 때까지 기다립니다. 이것은 이해하기 쉽지만 호출 detach()과 호출하지 않는 것의 차이점은 무엇 입니까?
이 없으면 detach()스레드의 메소드는 스레드를 독립적으로 사용할 수 있다고 생각했습니다 .
분리하지 않음 :
void Someclass::Somefunction() {
//...
std::thread t([ ] {
printf("thread called without detach");
});
//some code here
}
분리로 전화 :
void Someclass::Somefunction() {
//...
std::thread t([ ] {
printf("thread called with detach");
});
t.detach();
//some code here
}
std와 boost스레드 한 detach및 joinPOSIX 스레드 후 밀접하게 모델링.