---
name: "pthread_create"
section: "3thr"
platform: "linux"
package: "glibc-doc"
version: "2.1.3-20"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/pthread_create/3thr"
---

# pthread\_create(3thr)

create a new thread

## NAME

pthread\_create - create a new thread

## SYNOPSIS

**#include \<pthread.h\>**

**int pthread\_create(pthread\_t \*** *thread***, pthread\_attr\_t \*** *attr***, void \* (\****start\_routine***)(void \*), void \*** *arg***);**

## DESCRIPTION

**pthread\_create** creates a new thread of control that executes concurrently with the calling thread. The new thread applies the function  *start\_routine* passing it  *arg* as first argument. The new thread terminates either explicitly, by calling  [**pthread\_exit**(3)](/pthread_exit/3.md), or implicitly, by returning from the  *start\_routine* function. The latter case is equivalent to calling  [**pthread\_exit**(3)](/pthread_exit/3.md) with the result returned by  *start\_routine* as exit code.

The  *attr* argument specifies thread attributes to be applied to the new thread. See  [**pthread\_attr\_init**(3)](/pthread_attr_init/3.md) for a complete list of thread attributes. The  *attr* argument can also be  **NULL**, in which case default attributes are used: the created thread is joinable (not detached) and has default (non real-time) scheduling policy.

## RETURN VALUE

On success, the identifier of the newly created thread is stored in the location pointed by the  *thread* argument, and a 0 is returned. On error, a non-zero error code is returned.

## ERRORS

- **EAGAIN**

  not enough system resources to create a process for the new thread, or more than  **PTHREAD\_THREADS\_MAX** threads are already active.

## AUTHOR

Xavier Leroy \<Xavier.Leroy@inria.fr\>

## SEE ALSO

[**pthread\_exit**(3)](/pthread_exit/3.md), [**pthread\_join**(3)](/pthread_join/3.md), [**pthread\_detach**(3)](/pthread_detach/3.md), [**pthread\_attr\_init**(3)](/pthread_attr_init/3.md).
