##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# thread_create

From cppreference.com
< c‎ | thread

Defined in header `<threads.h>` |  |
int thrd_create( thrd_t *thr, thrd_start_t func, void *arg ); |  | (since C11)

Creates a new thread executing the function `func`. The function is invoked as func(arg).

If successful, the object pointed to by `thr` is set to the identifier of the new thread.

The completion of this function synchronizes with the beginning of the thread.

### [edit] Parameters

thr | - | pointer to memory location to put the identifier of the new thread
func | - | function to execute
arg | - | argument to pass to the function

### [edit] Return value

thrd_success if the creation of the new thread was successful. Otherwise returns thrd_nomem if there was insufficient amount of memory or `thrd_error` if another error occurred.

### [edit] Notes

The thread identifies may be reused for new threads once the thread has finished and joined or detached.

### [edit] See also

thrd_detach (C11) | detaches a thread (function) [edit]
thrd_join (C11) | blocks until a thread terminates (function) [edit]

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