GLib.Thread.try_new
Description: Reference for GLib.Thread.try_new

### Function

# GLib Threadtry_new

since: 2.32

#### Declaration [src]

    GThread*
    g_thread_try_new (
      const gchar* name,
      GThreadFunc func,
      gpointer data,
      GError** error
    )

#### Description [src]

This function is the same as `g_thread_new()` except that it allows for the possibility of failure.

If a thread can not be created (due to resource limits), `error` is set and `NULL` is returned.

Available since: 2.32

#### Parameters

`name`

  Type: `const gchar*`

  An (optional) name for the new thread.

  The argument can be `NULL`.
  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`func`

  Type: `GThreadFunc`

  A function to execute in the new thread.

`data`

  Type: `gpointer`

  An argument to supply to the new thread.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GThread`

The new `GThread`, or `NULL` if an error occurred.

The caller of the function takes ownership of the data, and is responsible for freeing it.