GLib.ThreadPool.set_max_threads

### Method

# GLib ThreadPoolset_max_threads

#### Declaration [src]

    gboolean
    g_thread_pool_set_max_threads (
      GThreadPool* pool,
      gint max_threads,
      GError** error
    )

#### Description [src]

Sets the maximal allowed number of threads for `pool`. A value of -1 means that the maximal number of threads is unlimited. If `pool` is an exclusive thread pool, setting the maximal number of threads to -1 is not allowed.

Setting `max_threads` to 0 means stopping all work for `pool`. It is effectively frozen until `max_threads` is set to a non-zero value again.

A thread is never terminated while calling `func`, as supplied by g_thread_pool_new(). Instead the maximal number of threads only has effect for the allocation of new threads in g_thread_pool_push(). A new thread is allocated, whenever the number of currently running threads in `pool` is smaller than the maximal number.

`error` can be `NULL` to ignore errors, or non-`NULL` to report errors. An error can only occur when a new thread couldn’t be created.

Before version 2.32, this function did not return a success status.

#### Parameters

`max_threads`

  Type: `gint`

  A new maximal number of threads for `pool`, or -1 for unlimited.

`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 method 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: `gboolean`

`TRUE` on success, `FALSE` if an error occurred.