Share via


thread::detach Method

Detaches the associated thread. The operating system becomes responsible for releasing thread resources on termination.

void detach();

Remarks

After a call to detach, subsequent calls to get_id return id.

If the thread that's associated with the calling object is not joinable, the function throws a system_error that has an error code of invalid_argument.

If the thread that's associated with the calling object is invalid, the function throws a system_error that has an error code of no_such_process.

Requirements

Header: thread

Namespace: std

See Also

Reference

thread Class

<thread>