---
name: "SDL_WaitThread"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_WaitThread"
---

# SDL\_WaitThread(3)

Wait for a thread to finish.

## NAME

SDL\_WaitThread - Wait for a thread to finish.

## HEADER FILE

Defined in SDL3/SDL\_thread.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**void SDL\_WaitThread(SDL\_Thread \*thread, int \*status);**

## DESCRIPTION

Threads that haven't been detached will remain until this function cleans them up. Not doing so is a resource leak.

Once a thread has been cleaned up through this function, the

**SDL\_Thread**\
  that references it becomes invalid and should not be referenced again. As such, only one thread may call

**SDL\_WaitThread** () on another.

The return code from the thread function is placed in the area pointed to by **status** , if **status** is not NULL.

You may not wait on a thread that has been used in a call to

**SDL\_DetachThread** (). Use either that function or this one, but not both, or behavior is undefined.

It is safe to pass a NULL thread to this function; it is a no-op.

Note that the thread pointer is freed by this function and is not valid afterward.

## FUNCTION PARAMETERS

- *thread*

  the  **SDL\_Thread**\
    pointer that was returned from the  **SDL\_CreateThread** () call that started this thread.

- *status*

  a pointer filled in with the value returned from the thread function by its 'return', or -1 if the thread has been detached or isn't valid, may be NULL.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_CreateThread**(3)](/SDL_CreateThread/3.md), **•**(3), [**SDL\_DetachThread**(3)](/SDL_DetachThread/3.md)
