# groonga - An open-source fulltext search engine and column store.

- 日本語

# 7.3.67. `thread_limit`

## 7.3.67.1. Summary

New in version 5.0.7.

`thread_limit` has the following two features:

> - It returns the max number of threads.

> - It sets the max number of threads.

groonga executable file is the only Groonga server that supports full `thread_limit` features.

groonga-httpd supports only one feature that returns the max number of threads. The max number of threads of groonga-httpd always returns `1` because groonga-httpd uses single thread model.

If you’re using Groonga as a library, `thread_limit` doesn’t work without you set custom functions by `grn_thread_set_get_limit_func()` and `grn_thread_set_set_limit_func()`. If you set a function by `grn_thread_set_get_limit_func()`, the feature that returns the max number of threads works. If you set a function by `grn_thread_set_set_limit_func()`, the feature that sets the max number of threads works.

## 7.3.67.2. Syntax

This command takes only one optional parameter:

    thread_limit [max=null]

## 7.3.67.3. Usage

You can get the max number of threads by calling without any parameters:

Execution example:

    thread_limit
    # [[0, 1337566253.89858, 0.000355720520019531], 2]

If it returns `0`, your Groonga server doesn’t support the feature.

You can set the max number of threads by calling `max` parameter:

Execution example:

    thread_limit --max 4
    # [[0, 1337566253.89858, 0.000355720520019531], 2]

It returns the previous max number of threads when you pass `max` parameter.

## 7.3.67.4. Parameters

This section describes all parameters.

### 7.3.67.4.1. Required parameters

There is no required parameter.

### 7.3.67.4.2. Optional parameters

There is one optional parameter.

#### 7.3.67.4.2.1. `max`

Specifies the new max number of threads.

You must specify positive integer:

Execution example:

    thread_limit --max 3
    # [[0, 1337566253.89858, 0.000355720520019531], 4]

If you specify `max` parameter, `thread_limit` returns the max number of threads before `max` is applied.

## 7.3.67.5. Return value

The command returns the max number of threads as body:

    [HEADER, N_MAX_THREADS]

If `max` is specified, `N_MAX_THREADS` is the max number of threads before `max` is applied.

See Output format for `HEADER`.