##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# mtx_init

From cppreference.com
< c‎ | thread

Defined in header `<threads.h>` |  |
int mtx_init( mtx_t* mutex, int type ); |  | (since C11)

Creates a new mutex object with `type`. The object pointed to by `mutex` is set to an identifier of the newly created mutex.

`type` must have one of the following values:

- mtx_plain - a simple, non-recursive mutex is created.
- mtx_timed - a non-recursive mutex, that supports timeout, is created.
- mtx_plain | mtx_recursive - a recursive mutex is created.
- mtx_timed | mtx_recursive - a recursive mutex, that supports timeout, is created.

### [edit] Parameters

mutex | - | pointer to the mutex to initialize
type | - | the type of the mutex

### [edit] Return value

thrd_success if successful, thrd_error otherwise.

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/thread/mtx_init&oldid=63546"