# thrd_detach

> C++ Atlas: `cppatlas.com/w/c/thread/thrd_detach` | Source: https://en.cppreference.com/w/c/thread/thrd_detach | Domain: Concurrency support | Standards: C11

Detaches the thread identified by thr from the current environment. The resources held by the thread will be freed automatically once the thread exits.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <threads.h>
int thrd_detach( thrd_t thr ); // (since C11)
```

Detaches the thread identified by `thr` from the current environment. The resources held by the thread will be freed automatically once the thread exits.

### Parameters

- `thr` - identifier of the thread to detach

### Return value

`thrd_success` if successful, `thrd_error` otherwise.

### References

- C17 standard (ISO/IEC 9899:2018):

  - 7.26.5.3 The thrd_detach function (p: 280)

- C11 standard (ISO/IEC 9899:2011):

  - 7.26.5.3 The thrd_detach function (p: 383-384)

### See also

- [`thrd_join`](https://en.cppreference.com/w/c/thread/thrd_join) (C11): blocks until a thread terminates (function)
- [C++ documentation for `detach`](https://en.cppreference.com/w/cpp/thread/thread/detach)

---
Attribution: content from https://en.cppreference.com/w/c/thread/thrd_detach (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.