### Method

# GLib Thread join

#### Declaration

    gpointer
    g_thread_join (
      GThread* thread
    )

#### Description

Waits until `thread` finishes, i.e. the function `func`, as given to g_thread_new(), returns or `g_thread_exit()` is called. If `thread` has already terminated, then `g_thread_join()` returns immediately.

Any thread can wait for any other thread by calling g_thread_join(), not just its ‘creator’. Calling `g_thread_join()` from multiple threads for the same `thread` leads to undefined behaviour.

The value returned by `func` or given to `g_thread_exit()` is returned by this function.

`g_thread_join()` consumes the reference to the passed-in `thread`. This will usually cause the `GThread` struct and associated resources to be freed. Use `g_thread_ref()` to obtain an extra reference if you want to keep the GThread alive beyond the `g_thread_join()` call.

#### Return value

Type: `gpointer`

The return value of the thread.

The caller of the method takes ownership of the data, and is responsible for freeing it.
The return value can be `NULL`.